Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dboulytchev committed Jan 24, 2024
1 parent d7d0299 commit cc82310
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
7 changes: 7 additions & 0 deletions L3/t01.l3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let a = 1 in
let f = { -> write (a)} in
let a = 5 in
f ();
write (a)
-- input: none
-- output: 1 5
11 changes: 11 additions & 0 deletions L3/t02.l3
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let f = {f n ->
write (n);
if n == 0
then 0
else f (f, n-1)
fi
}
in
write (f (f, 5))
-- input: none
-- output: 5 4 3 2 1 0 0
10 changes: 10 additions & 0 deletions L3/t03.l3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let fact = { f -> {n ->
if n < 2
then 1
else n * f (f)( n-1)
fi
}}
in
write (fact (fact)(5))
-- input: none
-- output: 120
15 changes: 15 additions & 0 deletions L3/t04.l3
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let z = {f ->
{x -> f ({z -> x(x)(z)})}
({x -> f ({z -> x(x)(z)})})
}
in
let f = {f -> {n ->
if n < 2
then 1
else n * f (n-1)
fi
}}
in
write (z (f) (5))
-- input: none
-- output: 120
7 changes: 7 additions & 0 deletions L3/t05.l3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let f = {n -> {k -> n + k}} in
let g = f (5) in
write (f (5)(6));
write (g (6));
write (g(7))
-- input: none
-- output: 11 11 12
10 changes: 10 additions & 0 deletions L3/t06.l3
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let f = {f n ->
if n < 2
then 1
else n * f (f, n-1)
fi
}
in
write (f (f, 5))
-- input: none
-- output: 120

0 comments on commit cc82310

Please sign in to comment.