This is an alpha release of the Lambda Calculus interpreter. (Built using VS2010 Beta 1)
The interpreter is fully functional.
In order to type the lambda symbol "λ" just press the "\" Key.
These are some example of the many lambda expression that can be paste it into the interpreter.
Identity
(λx.x) (λy.y)
Succ 2 (Using Church Encoding)
(λn.λf.λx.(f (n f x))) (λf.λx.(f (f x)))
Add 2 3
(λm.λn.λf.λx.((m f) (n f x))) (λh.λx.(h (h x))) (λg.λx.(g (g (g x))))
Many examples of Lambda expressions can be found in the InterpreterTests.fs file.
Typical Recursion Example:
The Factorial of 5
Macros (The console app doesn't support macros at the moment. They are used in the tests to make them more readable)
fix := (λf.((λx.(f (λy.(x x y)))) (λx.(f (λy.(x x y))))))
ifThenElse := λp.λa.λb.(p a b)
true:= λx.λy.x
false:= λx.λy.y
isZero:= (λn.(n (λx.(false)) (true)))
1:= (λf.(λx.(f x)))
mult := (λm.λn.λf.(n (m f)))
5:=(λf.(λx.(f (f (f (f (f x)))))))
pred:=(λn.λf.λx.(n (λg.λh.(h (g f))) (λu.x) (λu.u)))
This is the Factorial of 5 with the macros. (All macros need to be replaced before pasting the following in the interpreter)
fix (λk.λi.((ifThenElse) (iszero i) 1 (mult i (k (pred i))))) 5
This is the Factorial of 5 with all the macros replaced. If you paste this in the interpreter, what you get is the Church Numeral 120.
(λf.((λx.(f (λy.(x x y)))) (λx.(f (λy.(x x y)))))) (λk.λi.((λp.λa.λb.(p a b)) ((λn.(n (λx.(λx.λy.y)) (λx.λy.x))) i) (λf.(λx.(f x))) ((λm.λn.λf.(n (m f))) i (k ((λn.λf.λx.(n (λg.λh.(h (g f))) (λu.x) (λu.u))) i))))) (λf.(λx.(f (f (f (f (f x)))))))
Enjoy learning the foundation of functional programming in F#.
Edmondo