- Compiled Lambda Calc Files have an
LCC_
Prefix & become native JavaScript - See JS_LambdaCalc_SampleExec.js's compilation into LCC_JS_LambdaCalc_SampleExec.js for more!
lci> EXIT
exit REPLlci> SYNTAX-HELP
show Lambda Calculus syntax guidelci> HELP
show this message
lci> LCC filename
compile + exitlci> LCI filename
interpret/evaluate + exitlci> COMPILE filename
compilelci> LOAD filename
interpret & load into REPL's history buffer
lci> SHOW-HISTORY
print REPL historylci> SAVE-HISTORY filename
save REPL history to "filename"lci> CLEAR-HISTORY
clear REPL historylci> DELETE lineNumber
delete code at "lineNumber"lci> REPLACE lineNumber newCode
rewrite "lineNumber" w/ "newCode"lci> INSERT lineNumber newCode
insert "newCode" PRIOR "lineNumber"
lci> LOAD-LIB
load lambdas from JS_LambdaCalc_SampleExec.jslci> LOAD-PRINT
load printingshow
lambdaslci> LOAD-CHURCH
load church numeral lambdas
lci> @JS your_JS_expr
run "your_JS_expr" as JavaScriptlci> your_LC_expr
interpret & run your Lambda Calculus!
- WHITESPACE +
. \ ( ) @
- LAMBDAS START W/ CAPITAL LETTER & ONLY HAVE ALPHANUMERICS +
_
- DATA (ARGS IN LAMBDAS) ARE A SINGLE LOWERCASE LETTER
LambdaName := \<args>.<returned operation>
- IMMUTABLE
- CURRY ARGS
- RETURN THEIR BODY
- SWAP BTWN "LAMBDA CALCULUS" & "JAVASCRIPT" SCOPES VIA TAGS:
@JS
= ALL FOLLOWING CODE IS JAVASCRIPT TO BE LEFT AS IS@LC
= ALL FOLLOWING CODE IS LAMBDA CALC TO BE CONVERTED
@JS
.. your JS here ..
@LC
.. your Lambda Calculus here ..
- ALL DATA IS IMMUTABLE (
CONST
) - ALL LAMBDAS ARE CURRIED ( IE
Add(ox1, ox2)
=>Add(ox1)(ox2)
) - CAPTURE SCOPE BY VALUE (using
[=]
) FOR INNER - CURRIED! - LAMBDAS
- let N = Church Numeral, B = Fcnal Bool, F1 = Unary Fcn, F2 = Binary Fcn,
F = arbitrary fcn, X = arbitrary data,
L = Fcnal List Data Structure (See More Below)
-
show(X)
=> print arbitrary data x to screen + newline -
print(X)
=> print arbitrary data x to screen -
bshow(B)
=> print fcnal boolean as boolean boolean + newline -
bprint(B)
=> print fcnal boolean as boolean boolean -
nshow(N)
=> print church numeral asunsigned long long
+ newline -
nprint(N)
=> print church numeral asunsigned long long
- Fcnal Booleans are Binary Fcns, acting like C++'s Ternary
?:
operator:- Fcnal
True
chooses arg1,False
chooses arg2
- Fcnal
True
False
Not (B)
And (B1)(B2)
Or (B1)(B2)
Xor (B1)(B2)
Beq (B1)(B2)
=> 'B'oolean 'eq'uality, ie xnor
- N-Fold Compositions of a Fcn (!!! ALL >= Zero Integers !!!):
- IE
Zero
=a
,Once
=f(a)
,Twice
=f(f(a))
,Thrice
=f(f(f(a)))
, etc
- IE
Zero
,Once
,Twice
,Thrice
,Fourfold
,Fivefold
ox0
,ox1
,ox2
,ox3
,ox4
,ox5
,ox6
,ox7
,ox8
,ox9
,oxa
,oxb
,oxc
,oxd
,oxe
,oxf
-
Is0 (N)
=> Equal to 'Zero' -
Eq (N1)(N2)
=> Equal-to -
Lt (N1)(N2)
=> Less Than -
Gt (N1)(N2)
=> Greater Than -
Leq (N1)(N2)
=> Less Than Or Equal-to -
Geq (N1)(N2)
=> Greater Than Or Equal-to -
IsFactor (N1)(N2)
=> N1 is a factor of N2 -
Evenp (N)
=> N is even -
Oddp (N)
=> N is odd
-
Add (N1)(N2)
=> N1 + N2 -
Sub (N1)(N2)
=> N1 - N2 -
Mult (N1)(N2)
=> N1 * N2 -
Pow (N1)(N2)
=> N1 ** N2 -
Div (N1)(N2)
=> N1 / N2 -
Log (N1)(N2)
=> log N1 (N2) -
Succ (N)
=> Succesor of N, N+1 -
Pred (N)
=> Predecessor of N, N-1 -
Factorial (N)
=> N! (w/o Loops, Recursion, or Mutability!!!) -
NumericSum (N)
=> Sum (0,N) -
NumericSumRange (N1)(N2)
=> Sum (N1,N2)
- Lists can contain ANYTHING: including integers, Church Numerals, & even other Lists!
ListN(N) (N1) (N2) (N3) (NN)
=> Returns List size N of the trailing elts
Length (L)
=> Returns length of LNullp (L)
=> "Null" 'p'redicate: List is EMPTYPairp (L)
=> "Pair" 'p'redicate: List is NOT EMPTY
Head (L)
=> Return L's 1st cell valueLast (L)
=> Return L's last cell valueNth (N)(L)
=> Returns L's 'N'th elt (starting from 'ox1')
Insert (N)(X)(L)
=> Returns List w/ X inserted in L AFTER nth positionErase (N)(L)
=> Returns List w/ L's nth value erasedPush (X)(L)
=> Returns List w/ X in front of LPop (L)
=> Returns List w/o L's Head- NOTE: "_back" versions may be self-implemented via "
Backward
" fcn (More Below)
- NOTE: "_back" versions may be self-implemented via "
Filter (F1)(L)
=> Returns List having filtered out elts from L NOT passing F1Map (F1)(L)
=> Returns List having mapped F1 across all of L's eltsVoidMap (F1)(L)
=> Returns Void & F1 Must be void, Apply Fcn to each elt in L
- NOTE
VoidMap
helps passing "printer" fcns (ienshow
) to print each elt
- NOTE
Reverse (L)
=> Returns List of L in reverseFlipArgs (F2)
=> Flips args for a Binary FcnBackward (F1)(L)
=> Returns List having applied F onReverse(L)
BackwardAtomic (F1)(L)
=> Returns Atom (IE Non-List Fcn) having applied F onReverse(L)
Foldl (F2)(X)(L)
=> Applies F2 on L from 'l'eft to right, starting w/ 'X' &Head(L)
Foldr (F2)(X)(L)
=> Applies F2 on L from 'r'ight to left, starting w/ 'X' &Last(L)
Max (L)
=> Returns Greatest value in ListMin (L)
=> Returns Smallest value in List
car (L)
=> Returns Current Cell Value ( IE Head(L) )cdr (L)
=> Returns Next Cell ( IE Pop(L) )cadr (L)
=> Head(Pop(L))caddr (L)
=> Head(Pop(Pop(L)))cadddr (L)
=> Head(Pop(Pop(Pop(L))))- Nested-List Access => Any permutation (length 1-4) of 'a' & 'd' btwn 'c' & 'r'!
- Part 1: https://www.youtube.com/watch?v=3VQ382QG-y4&feature=youtu.be
- Part 2: https://www.youtube.com/watch?v=pAnLQ9jwN-E
-
Identity/Once, Idiot:
I := \a.a
-
First/True/Const, Kestrel:
K := \ab.a
-
Flip/LogicalNot, Cardinal:
C := \fab.fba
-
Unary Compose, Bluebird:
B := \fga.f(ga)
-
Self-Replication, Mockingbird
M := \f.f(f)
=> IMPOSSIBLE IN HASKELL (Infinite Data Struct) -
Second/False/Zero, Kite:
KI := \ab.b = K I = C K
-
Binary Compose, Blackbird:
B1 := \fgab.f(gab) = B B B
-
Singleton/HoldArg, Thrush:
Th := \af.fa = C I
-
Tuple/HoldArgPair, Vireo:
V := \abf.fab = B C Th = B C (C I)