Add test if_func
This commit is contained in:
parent
7c6e2e390e
commit
faa31d90dd
2 changed files with 28 additions and 0 deletions
2
src/tests/if_func.exp
Normal file
2
src/tests/if_func.exp
Normal file
|
@ -0,0 +1,2 @@
|
|||
1
|
||||
1
|
26
src/tests/if_func.lambda
Normal file
26
src/tests/if_func.lambda
Normal file
|
@ -0,0 +1,26 @@
|
|||
let i = fun x -> x in
|
||||
let k = fun x -> fun y -> x in
|
||||
let zero = fun f -> i in
|
||||
let one = fun f -> fun x -> f x in
|
||||
let plus = fun m -> fun n -> fun f -> fun x -> m f (n f x) in
|
||||
let succ = plus one in
|
||||
let mult = fun m -> fun n -> fun f -> m (n f) in
|
||||
let exp = fun m -> fun n -> n m in
|
||||
let two = succ one in
|
||||
let three = succ two in
|
||||
let six = mult two three in
|
||||
let seven = succ six in
|
||||
let twenty_one = mult three seven in
|
||||
let forty_two = mult two twenty_one in
|
||||
let convert = fun n -> n (fun x -> x + 1) 0 in
|
||||
|
||||
let nothing =
|
||||
ifzero convert forty_two then
|
||||
print 0
|
||||
else
|
||||
print 1
|
||||
in
|
||||
ifzero convert zero then
|
||||
print 1
|
||||
else
|
||||
print 0
|
Loading…
Reference in a new issue