diff --git a/L3/t01.l3 b/L3/t01.l3 new file mode 100644 index 0000000..b3487a4 --- /dev/null +++ b/L3/t01.l3 @@ -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 \ No newline at end of file diff --git a/L3/t02.l3 b/L3/t02.l3 new file mode 100644 index 0000000..803f8cc --- /dev/null +++ b/L3/t02.l3 @@ -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 diff --git a/L3/t03.l3 b/L3/t03.l3 new file mode 100644 index 0000000..a7897d0 --- /dev/null +++ b/L3/t03.l3 @@ -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 diff --git a/L3/t04.l3 b/L3/t04.l3 new file mode 100644 index 0000000..df0f751 --- /dev/null +++ b/L3/t04.l3 @@ -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 \ No newline at end of file diff --git a/L3/t05.l3 b/L3/t05.l3 new file mode 100644 index 0000000..30d0a41 --- /dev/null +++ b/L3/t05.l3 @@ -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 \ No newline at end of file diff --git a/L3/t06.l3 b/L3/t06.l3 new file mode 100644 index 0000000..368aedb --- /dev/null +++ b/L3/t06.l3 @@ -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 \ No newline at end of file