a very shitty lambda calculus.
- literally just untyped lambda calculus.
- no named parameters, only de bruijn indices written as multiple dots.
- you can write ints but they're just syntax sugar for church numerals.
- the evaluator is really bad right now and will die on anything recursive. (to be fixed later.)
- basic subtraction can take, like, between seconds and minutes to run.
- lambda:
\ - access closest variable:
., second closest:.. - numerals:
0,1,2, ... - call
awithbas an argument:a b - left associative:
a b cis(a b) c - create a global variable:
name: value
so, the identity function \..
the church encoding of the number two — \\.. (.. .).
i've implemented a couple of basic definitions:
true: \\..
false: \\.
pair: \\\. ... ..
first: \. true
second: \. false
ident: \.
if: ident
pred: \\\... (\\. (.. ....)) (\..) (\.)
succ: (+ 1)
+: \\\\.... .. (... .. .)
*: \\\\.... (... ..) .
-: \\(. pred) ..
/: \\\\ ((.... \\. ..) \..) ((.... \((.... \\. ..) \(.... (. ..))) \.) .)
exp: \\. ..
&&: \\.. . ..
||: \\.. .. .
is_0: \. (\false) true
<=: \\is_0 (- .. .)
==: \\&& (<= .. .) (<= . ..)
opam switch create .
dune exec lamb