Add functions and lists
This commit is contained in:
11
tests/fibonacci.ppl
Normal file
11
tests/fibonacci.ppl
Normal 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
6
tests/functions.ppl
Normal 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)
|
||||
Reference in New Issue
Block a user