Add complicated recursion and nesting -- fail

This commit is contained in:
Théophile Bastian 2018-02-16 01:40:23 +01:00
parent c84a1ac169
commit 450595ab57
2 changed files with 34 additions and 0 deletions

9
src/tests/rec_fibo.exp Normal file
View file

@ -0,0 +1,9 @@
1
1
2
3
5
8
13
21
34

25
src/tests/rec_fibo.lambda Normal file
View file

@ -0,0 +1,25 @@
let fibo = fun n ->
let rec fibo_inner = fun i -> fun last -> fun last_last ->
ifzero (n - i) then
last + last_last
else
fibo_inner (i+1) (last + last_last) last
in
ifzero n then
1
else ifzero (n - 1) then
1
else
fibo_inner 2 1 1
in
let x = print fibo 0 in
let x = print fibo 1 in
let x = print fibo 2 in
let x = print fibo 3 in
let x = print fibo 4 in
let x = print fibo 5 in
let x = print fibo 6 in
let x = print fibo 7 in
print fibo 8