Functional Programming Language based on Lambda Calculus highly inspired by this video Programming with Math | The Lambda Calculus - Eyesomorphic made from scratch, entirely in
C++.
- CMake (version 3.16+ recommended)
- Python 3.8+ (for development environment and tooling)
- A C++17 capable compiler (e.g.
g++,clang++, or MSVC on Windows)
bash ./scripts/setup.sh. .\scripts\setup.ps1Booleans and If-Then construct built entirely using Lambda Expressions.
true: Bool = \x: Any. \y: Any. x
false: Bool = \x: Any. \y: Any. y
if_then: Any = \condition: Any.
\then_clause: Any. \else_clause: Any.
(condition then_clause else_clause)
(print (if_then true "True" "False"))
(print (if_then false "True" "False"))$ ./cmake-build-debug/lbd -f ./examples/if_then.lbd
True
FalseShapes Demo
-- Define Pi as constant
pi: Float = 3.14
-- Define function to calculate square
square: Float -> Float = \x: Float. (mul x x)
-- Define function to calculate area of circle
area_of_circle: Float -> Float = \r: Float.
(mul pi (square r))
-- Define function to calculate volume of cylinder
volume_of_cylinder: Float -> Float -> Float = \r: Float.
\h: Float. (mul (area_of_circle r) h)
-- Calculate the volume of a cylinder
(print "Volume of cylinder is: ")
(print (volume_of_cylinder 5.0 10.0))$ ./cmake-build-debug/lbd -f ./examples/shapes.lbd
Volume of cylinder is:
785.000000Fibonacci
fibonacci: Any = \num: Float.
(if_zero (cmp 0 num) 0
(if_zero (cmp 1 num) 1
(add (fibonacci (sub num 1.0)) (fibonacci (sub num 2.0)))))
(print (fibonacci 10))$ ./cmake-build-debug/lbd -f ./examples/math_demos.lbd
55.000000After building, you can run the interpreter with:
lbd [options]-f, --file <filepath> Specify input source filepath to run
-h, --help Show this help message and exit
-d, --debug Enable debug mode
-r, --repl Run in interactive REPL mode
- TODO: Add better examples (e.g., Advent of Code snippets).
- TODO: Maybe use rere.py for testing