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.ps1python tests/tests.pyBooleans and If-Then construct built entirely using Lambda Expressions.
true: Bool = \x: Any. \y: Any. x
false: Bool = \x: Any. \y: Any. y
if: Any = \condition: Any.
\thenClause: Any. \elseClause: Any.
(condition thenClause elseClause)
boolToString: Bool = \bool: Bool. (if bool "true" "false")
(print (boolToString true) "\n")
(print (boolToString false) "\n")$ ./cmake-build-debug/lbd -f ./examples/conditional_branching.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
areaOfCircle: Float -> Float = \r: Float.
(mul pi (square r))
-- Define function to calculate volume of cylinder
volumeOfCylinder: Float -> Float -> Float = \r: Float.
\h: Float. (mul (areaOfCircle r) h)
-- Calculate the volume of a cylinder
(print "Volume of cylinder is: " (volumeOfCylinder 5.0 10.0) "\n")$ ./cmake-build-debug/lbd -f ./examples/shapes.lbd
Volume of cylinder is: 785.000000Fibonacci
fibonacci: Any = \num: Float.
(null (cmp 0 num) 0
(null (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 node
--docs Generate language-reference-document
Generate the language-reference-document by using the
--docsflag, and use it as the source of truth for native-function-signatures.
- TODO: Add better examples (e.g., Advent of Code snippets).
- TODO: CI/CD for testing.
- TODO: Fix tests output in README.
- TODO: Step debug kind of functionality in REPL. Inside REPL, while loading a file, load one expression at a time and provide user with some feedback and actions to perform.
- TODO: Make a pre-commit-hook which does not allow to push to master, if the tests are failing. Additionally, test whether the
docs/SIGNATURE.txtis up-to-date or not.