Add functions and lists

This commit is contained in:
2025-11-15 13:52:23 +11:00
parent 18fadc18ed
commit c9c00e219d
4 changed files with 283 additions and 8 deletions

11
tests/fibonacci.ppl Normal file
View File

@@ -0,0 +1,11 @@
(let fib (function int [int y function fib]
(let retval 0)
(if (== 1 y) (set retval 0))
(if (== 2 y) (set retval 1))
(if (> y 2)
(set retval (+ (fib (- y 1) fib) (fib (- y 2) fib)))
)
(return retval)
))
(print (fib 30 fib))

6
tests/functions.ppl Normal file
View File

@@ -0,0 +1,6 @@
(let x (function int [function in int num]
(print "recursively called" (+ num 1) "times")
(in in (+ num 1))
))
(x x 1)