Skip to content
This repository was archived by the owner on Oct 12, 2026. It is now read-only.

Commit cacc9c3

Browse files
committed
docs: update README
1 parent eab1b39 commit cacc9c3

2 files changed

Lines changed: 72 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
> Functional Programming Language based on [Lambda Calculus](https://en.wikipedia.org/wiki/Lambda_calculus) highly
2+
> inspired by this video [Programming with Math | The Lambda Calculus - Eyesomorphic](https://youtu.be/ViPNHMSUcog) made
3+
> from scratch, entirely in `C++`.
4+
15
## Getting Started
26

37
### Prerequisites
@@ -22,6 +26,72 @@ bash ./scripts/setup.sh
2226

2327
---
2428

29+
## Samples
30+
31+
Booleans and If-Then construct built entirely using Lambda Expressions.
32+
33+
```haskell
34+
true: Bool = \x: Any. \y: Any. x
35+
false: Bool = \x: Any. \y: Any. y
36+
37+
if_then: Any = \condition: Any.
38+
\then_clause: Any. \else_clause: Any.
39+
(condition then_clause else_clause)
40+
41+
(print (if_then true "True" "False"))
42+
(print (if_then false "True" "False"))
43+
```
44+
45+
```console
46+
$ ./cmake-build-debug/lbd.exe -f ./examples/if_then.lbd
47+
True
48+
False
49+
```
50+
51+
Shapes Demo
52+
53+
```haskell
54+
-- Define Pi as constant
55+
pi: Float = 3.14
56+
57+
-- Define function to calculate square
58+
square: Float -> Float = \x: Float. (mul x x)
59+
60+
-- Define function to calculate area of circle
61+
area_of_circle: Float -> Float = \r: Float.
62+
(mul pi (square r))
63+
64+
-- Define function to calculate volume of cylinder
65+
volume_of_cylinder: Float -> Float -> Float = \r: Float.
66+
\h: Float. (mul (area_of_circle r) h)
67+
68+
-- Calculate the volume of a cylinder
69+
(print "Volume of cylinder is: ")
70+
(print (volume_of_cylinder 5.0 10.0))
71+
```
72+
73+
```console
74+
$ ./cmake-build-debug/lbd -f ./examples/shapes.lbd
75+
Volume of cylinder is:
76+
785.000000
77+
```
78+
79+
Fibonacci
80+
81+
```haskell
82+
fibonacci: Any = \num: Float.
83+
(if_zero (cmp 0 num) 0
84+
(if_zero (cmp 1 num) 1
85+
(add (fibonacci (sub num 1.0)) (fibonacci (sub num 2.0)))))
86+
87+
(print (fibonacci 10))
88+
```
89+
90+
```console
91+
$ ./cmake-build-debug/lbd -f ./examples/math_demos.lbd
92+
55.000000
93+
```
94+
2595
## Usage
2696

2797
After building, you can run the interpreter with:
@@ -49,5 +119,5 @@ lbd [options]
49119

50120
## TODO
51121

52-
- TODO: Provide better examples (e.g., Advent of Code snippets).
122+
- TODO: Add better examples (e.g., Advent of Code snippets).
53123
- TODO: Maybe use rere.py for testing

‎examples/if_then.lbd‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ if_then: Any = \condition: Any.
55
\then_clause: Any. \else_clause: Any.
66
(condition then_clause else_clause)
77

8-
98
(print (if_then true "True" "False"))
10-
(print (if_then false "True" "False"))
9+
(print (if_then false "True" "False"))

0 commit comments

Comments
 (0)