@@ -40,18 +40,20 @@ Booleans and If-Then construct built entirely using Lambda Expressions.
4040true: Bool = \ x: Any . \ y: Any . x
4141false: Bool = \ x: Any . \ y: Any . y
4242
43- if_then : Any = \ condition: Any .
44- \ then_clause : Any . \ else_clause : Any .
45- (condition then_clause else_clause )
43+ if : Any = \ condition: Any .
44+ \ thenClause : Any . \ elseClause : Any .
45+ (condition thenClause elseClause )
4646
47- (print (if_then true " True" " False" ))
48- (print (if_then false " True" " False" ))
47+ boolToString: Bool = \ bool: Bool . (if bool " true" " false" )
48+
49+ (print (boolToString true) " \n " )
50+ (print (boolToString false) " \n " )
4951```
5052
5153``` console
52- $ ./cmake-build-debug/lbd -f ./examples/if_then .lbd
53- True
54- False
54+ $ ./cmake-build-debug/lbd -f ./examples/conditional_branching .lbd
55+ true
56+ false
5557```
5658
5759Shapes Demo
@@ -64,30 +66,28 @@ pi: Float = 3.14
6466square: Float -> Float = \ x: Float . (mul x x)
6567
6668-- Define function to calculate area of circle
67- area_of_circle : Float -> Float = \ r: Float .
69+ areaOfCircle : Float -> Float = \ r: Float .
6870 (mul pi (square r))
6971
7072-- Define function to calculate volume of cylinder
71- volume_of_cylinder : Float -> Float -> Float = \ r: Float .
72- \ h: Float . (mul (area_of_circle r) h)
73+ volumeOfCylinder : Float -> Float -> Float = \ r: Float .
74+ \ h: Float . (mul (areaOfCircle r) h)
7375
7476-- Calculate the volume of a cylinder
75- (print " Volume of cylinder is: " )
76- (print (volume_of_cylinder 5.0 10.0 ))
77+ (print " Volume of cylinder is: " (volumeOfCylinder 5.0 10.0 ) " \n " )
7778```
7879
7980``` console
8081$ ./cmake-build-debug/lbd -f ./examples/shapes.lbd
81- Volume of cylinder is:
82- 785.000000
82+ Volume of cylinder is: 785.000000
8383```
8484
8585Fibonacci
8686
8787``` haskell
8888fibonacci: Any = \ num: Float .
89- (if_zero (cmp 0 num) 0
90- (if_zero (cmp 1 num) 1
89+ (null (cmp 0 num) 0
90+ (null (cmp 1 num) 1
9191 (add (fibonacci (sub num 1.0 )) (fibonacci (sub num 2.0 )))))
9292
9393(print (fibonacci 10 ))
0 commit comments