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

Commit 941a9ee

Browse files
committed
chore: update native function names
1 parent a3d98e4 commit 941a9ee

20 files changed

Lines changed: 98 additions & 96 deletions

‎README.md‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,20 @@ Booleans and If-Then construct built entirely using Lambda Expressions.
4040
true: Bool = \x: Any. \y: Any. x
4141
false: 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

5759
Shapes Demo
@@ -64,30 +66,28 @@ pi: Float = 3.14
6466
square: 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

8585
Fibonacci
8686

8787
```haskell
8888
fibonacci: 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))

‎docs/SIGNATURE.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ add: Float -> Float -> Float
66
sub: Float -> Float -> Float
77
mul: Float -> Float -> Float
88
cmp: Float -> Float -> Float
9-
if_zero: Float -> A -> B -> A|B
9+
null: Float -> A -> B -> A|B
1010
sort: List<Float> -> List<Float>
11-
parse_float: String -> Float
11+
parseFloat: String -> Float
1212

1313
-- List module
1414
list: Any... -> List
15-
list_size: List -> Float
16-
list_get: List -> Float -> Any
17-
list_remove: List -> Float -> Any
18-
list_append: List -> Any -> Void
15+
listSize: List -> Float
16+
listGet: List -> Float -> Any
17+
listRemove: List -> Float -> Any
18+
listAppend: List -> Any -> Void
1919
map: (A -> B) -> List<A> -> List<B>
2020
transpose: List<List> -> List<List>
2121
zip: List<List> -> List<List>
22-
foldr: (A -> B -> B) -> List<A> -> B -> B
22+
foldRight: (A -> B -> B) -> List<A> -> B -> B
2323

2424
-- IO module
25-
slurp_file: String -> String
25+
slurpFile: String -> String
2626
lines: String -> List<String>
2727
split: String -> String -> List<String>
2828
```

‎editor-plugins/emacs/lbd-mode.el‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636

3737
;; Font lock
3838
(defconst lbd--keywords
39-
'("true" "false" "if_then" "pair" "first" "second" "use"
40-
"print" "add" "sub" "mul" "cmp" "if_zero" "sort" "parse_float"
41-
"list" "list_size" "list_get" "list_remove" "list_append" "map" "transpose" "zip" "foldr"
42-
"slurp_file" "lines" "split")
39+
'("true" "false" "if" "pair" "first" "second" "use"
40+
"print" "add" "sub" "mul" "cmp" "null" "sort" "parseFloat"
41+
"list" "listSize" "listGet" "listRemove" "listAppend" "map" "transpose" "zip" "foldRight"
42+
"slurpFile" "lines" "split")
4343
"Language keywords for lbd-mode.")
4444

4545
(defvar lbd-font-lock-keywords

‎examples/aoc-24/day-01/part_01.lbd‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
use "examples/std.lbd"
44

5-
content: String = (slurp_file "examples/aoc-24/day-01/input.txt")
5+
content: String = (slurpFile "examples/aoc-24/day-01/input.txt")
66
entries: List = (lines content)
77

88
-- TODO: Add support for un-named Lambda Expressions
9-
tmp: String -> Any = \x: String. (rot_2 split " " x)
9+
tmp: String -> Any = \x: String. (rotate2 split " " x)
1010
cols: List = (transpose (map tmp entries))
1111

1212
-- TODO: Reassigning does not work
13-
tmp2: List -> Any = \x: List. (map parse_float x)
13+
tmp2: List -> Any = \x: List. (map parseFloat x)
1414
lists: List = (map sort (map tmp2 cols))
1515

16-
tmp3: List -> Float = \x: List. (abs (sub (list_get x 0) (list_get x 1)))
16+
tmp3: List -> Float = \x: List. (abs (sub (listGet x 0) (listGet x 1)))
1717
add2: Float -> Float -> Float = \x: Float. \y: Float. (add y x)
18-
res: Float = (foldr add2 0 (map tmp3 (zip lists)))
18+
res: Float = (foldRight add2 0 (map tmp3 (zip lists)))
1919
(print "Answer: " res "\n")

‎examples/aoc-24/day-01/part_02.lbd‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44

55
use "examples/std.lbd"
66

7-
content: String = (slurp_file "examples/aoc-24/day-01/input.txt")
7+
content: String = (slurpFile "examples/aoc-24/day-01/input.txt")
88
entries: List = (lines content)
99

10-
tmp: String -> Any = \x: String. (rot_2 split " " x)
10+
tmp: String -> Any = \x: String. (rotate2 split " " x)
1111
cols: List = (transpose (map tmp entries))
1212

13-
tmp2: List -> Any = \x: List. (map parse_float x)
13+
tmp2: List -> Any = \x: List. (map parseFloat x)
1414
lists: List = (map tmp2 cols)
1515

16-
eq2: Float -> Float -> Float = \x: Float. \y: Float. (if_then (eq y x) 1 0)
16+
eq2: Float -> Float -> Float = \x: Float. \y: Float. (if (eq y x) 1 0)
1717
add2: Float -> Float -> Float = \x: Float. \y: Float. (add y x)
1818

19-
count: List -> Any -> Float = \xs: List. \x: Any. (foldr add2 0 (map (eq2 x) xs))
19+
count: List -> Any -> Float = \xs: List. \x: Any. (foldRight add2 0 (map (eq2 x) xs))
2020

21-
l0: List = (list_get lists 0)
22-
l1: List = (list_get lists 1)
21+
l0: List = (listGet lists 0)
22+
l1: List = (listGet lists 1)
2323

24-
tmp3: List -> Float = \xs: List. (mul (list_get xs 0) (list_get xs 1))
24+
tmp3: List -> Float = \xs: List. (mul (listGet xs 0) (listGet xs 1))
2525

26-
(print "Answer: " (foldr add2 0 (map tmp3 (zip (list l0 (map (count l1) l0))))) "\n")
26+
(print "Answer: " (foldRight add2 0 (map tmp3 (zip (list l0 (map (count l1) l0))))) "\n")

‎examples/conditional_branching.lbd‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
true: Bool = \x: Any. \y: Any. x
2+
false: Bool = \x: Any. \y: Any. y
3+
4+
if: Any = \condition: Any.
5+
\thenClause: Any. \elseClause: Any.
6+
(condition thenClause elseClause)
7+
8+
boolToString: Bool = \bool: Bool. (if bool "true" "false")
9+
10+
(print (boolToString true) "\n")
11+
(print (boolToString false) "\n")

‎examples/if_then.lbd‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎examples/list.lbd‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
a: List = (list)
22
(print "list: " a "\n")
33

4-
(list_append a "Hello")
4+
(listAppend a "Hello")
55
(print "list: " a "\n")
66

7-
(print "list size: " (list_size a) "\n")
7+
(print "list size: " (listSize a) "\n")
88

9-
(list_append a "World")
9+
(listAppend a "World")
1010
(print "list: " a "\n")
11-
(print "list[1]: " (list_get a 1) "\n")
11+
(print "list[1]: " (listGet a 1) "\n")
1212

13-
(list_append a "Foo")
13+
(listAppend a "Foo")
1414
(print "list: " a "\n")
15-
(list_remove a 2)
15+
(listRemove a 2)
1616
(print "list: " a "\n")

‎examples/math_demos.lbd‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fibonacci: Any = \num: Float.
2-
(if_zero (cmp 0 num) 0
3-
(if_zero (cmp 1 num) 1
2+
(null (cmp 0 num) 0
3+
(null (cmp 1 num) 1
44
(add (fibonacci (sub num 1.0)) (fibonacci (sub num 2.0)))))
55

66
(print (fibonacci 10))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
true
2+
false

0 commit comments

Comments
 (0)