diff --git a/flap/tests/04-Hobix_to_Fopix/01-fact.expected b/flap/tests/04-Hobix_to_Fopix/01-fact.expected new file mode 100644 index 0000000..8bc6583 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/01-fact.expected @@ -0,0 +1 @@ +120 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/01-fact.hobix b/flap/tests/04-Hobix_to_Fopix/01-fact.hobix new file mode 100644 index 0000000..c56bbe6 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/01-fact.hobix @@ -0,0 +1,5 @@ +fun fact (n) = + if n =? 0 then 1 else n * fact (n - 1) fi + +val main = + print_int (fact (5)) diff --git a/flap/tests/04-Hobix_to_Fopix/02-addk.expected b/flap/tests/04-Hobix_to_Fopix/02-addk.expected new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/02-addk.expected @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/02-addk.hobix b/flap/tests/04-Hobix_to_Fopix/02-addk.hobix new file mode 100644 index 0000000..2afa7d7 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/02-addk.hobix @@ -0,0 +1,5 @@ +fun addk (k) = \(x) => x + k + +val f = addk (41) + +val main = print_int (f (1)) diff --git a/flap/tests/04-Hobix_to_Fopix/03-apply.expected b/flap/tests/04-Hobix_to_Fopix/03-apply.expected new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/03-apply.expected @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/03-apply.hobix b/flap/tests/04-Hobix_to_Fopix/03-apply.hobix new file mode 100644 index 0000000..98e1210 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/03-apply.hobix @@ -0,0 +1,3 @@ +fun apply (f, x) = f (x) + +val main = apply ((\(x) => print_int (x)), 42) diff --git a/flap/tests/04-Hobix_to_Fopix/04-curry.expected b/flap/tests/04-Hobix_to_Fopix/04-curry.expected new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/04-curry.expected @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/04-curry.hobix b/flap/tests/04-Hobix_to_Fopix/04-curry.hobix new file mode 100644 index 0000000..22050bf --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/04-curry.hobix @@ -0,0 +1,10 @@ +val curry = + \(f) => \(x) => \(y) => f (x, y) + +val add = \(x, y) => x + y + +val g = curry (add) + +val h = g (1) + +val main = print_int (h (41)) diff --git a/flap/tests/04-Hobix_to_Fopix/05-mutual-recursion.expected b/flap/tests/04-Hobix_to_Fopix/05-mutual-recursion.expected new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/05-mutual-recursion.expected @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/05-mutual-recursion.hobix b/flap/tests/04-Hobix_to_Fopix/05-mutual-recursion.hobix new file mode 100644 index 0000000..8342ec7 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/05-mutual-recursion.hobix @@ -0,0 +1,10 @@ +fun f (x) = + if x =? 0 then 1 + else g (x - 1) + fi +and g (x) = + if x =? 0 then 0 + else f (x - 1) + fi + +val main = print_int (f (20)) diff --git a/flap/tests/04-Hobix_to_Fopix/06-compose.expected b/flap/tests/04-Hobix_to_Fopix/06-compose.expected new file mode 100644 index 0000000..7ea2583 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/06-compose.expected @@ -0,0 +1 @@ +42424240 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/06-compose.hobix b/flap/tests/04-Hobix_to_Fopix/06-compose.hobix new file mode 100644 index 0000000..e7223ca --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/06-compose.hobix @@ -0,0 +1,12 @@ +fun compose (f, g) = + \(x) => f (g (x)) + +fun id (x) = x + +fun twice (x) = 2 * x + +val main = + print_int (twice (21)); + print_int (compose (id, twice) (21)); + print_int (compose (twice, id) (21)); + print_int (compose (twice, twice) (10)) \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/07-multiple-free-variables.expected b/flap/tests/04-Hobix_to_Fopix/07-multiple-free-variables.expected new file mode 100644 index 0000000..f70d7bb --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/07-multiple-free-variables.expected @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/07-multiple-free-variables.hobix b/flap/tests/04-Hobix_to_Fopix/07-multiple-free-variables.hobix new file mode 100644 index 0000000..39bbf4f --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/07-multiple-free-variables.hobix @@ -0,0 +1,7 @@ +val f = \(z) => + val x = z + 1; + val y = x; + val t = 0; + \(k) => k + x + +val main = print_int (f (21) (20)) \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/08-multiple-free-variables-and-rec.expected b/flap/tests/04-Hobix_to_Fopix/08-multiple-free-variables-and-rec.expected new file mode 100644 index 0000000..615be70 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/08-multiple-free-variables-and-rec.expected @@ -0,0 +1 @@ +85 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/08-multiple-free-variables-and-rec.hobix b/flap/tests/04-Hobix_to_Fopix/08-multiple-free-variables-and-rec.hobix new file mode 100644 index 0000000..7c22629 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/08-multiple-free-variables-and-rec.hobix @@ -0,0 +1,9 @@ +val f = \(z) => + val x = z + 1; + val y = x; + val t = 0; + fun g (x) = f(y + x, x) + and f (a, b) = z + a; + \(k) => g (k) + x + +val main = print_int (f (21) (20)) \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/09-curryNM.expected b/flap/tests/04-Hobix_to_Fopix/09-curryNM.expected new file mode 100644 index 0000000..cc98c81 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/09-curryNM.expected @@ -0,0 +1 @@ +3610152136101521 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/09-curryNM.hobix b/flap/tests/04-Hobix_to_Fopix/09-curryNM.hobix new file mode 100644 index 0000000..81d9613 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/09-curryNM.hobix @@ -0,0 +1,29 @@ +val curry_1_2 = \(f) => \(x) => \(y) => f (x, y) +val curry_1_3 = \(f) => \(x) => \(y1, y2) => f (x, y1, y2) +val curry_1_4 = \(f) => \(x) => \(y1, y2, y3) => f (x, y1, y2, y3) +val curry_1_5 = \(f) => \(x) => \(y1, y2, y3, y4) => f (x, y1, y2, y3, y4) +val curry_1_6 = \(f) => \(x) => \(y1, y2, y3, y4, y5) => f (x, y1, y2, y3, y4, y5) + +val f2 = \(x1, x2) => x1 + x2 +val f3 = \(x1, x2, x3) => x1 + x2 + x3 +val f4 = \(x1, x2, x3, x4) => x1 + x2 + x3 + x4 +val f5 = \(x1, x2, x3, x4, x5) => x1 + x2 + x3 + x4 + x5 +val f6 = \(x1, x2, x3, x4, x5, x6) => x1 + x2 + x3 + x4 + x5 + x6 + +val test1_2 = print_int (curry_1_2 (f2) (1) (2)) +val test1_3 = print_int (curry_1_3 (f3) (1) (2, 3)) +val test1_4 = print_int (curry_1_4 (f4) (1) (2, 3, 4)) +val test1_5 = print_int (curry_1_5 (f5) (1) (2, 3, 4, 5)) +val test1_6 = print_int (curry_1_6 (f6) (1) (2, 3, 4, 5, 6)) + +val curry_2_2 = \(f) => \(o, x) => \(y) => f (x, y) +val curry_2_3 = \(f) => \(o, x) => \(y1, y2) => f (x, y1, y2) +val curry_2_4 = \(f) => \(o, x) => \(y1, y2, y3) => f (x, y1, y2, y3) +val curry_2_5 = \(f) => \(o, x) => \(y1, y2, y3, y4) => f (x, y1, y2, y3, y4) +val curry_2_6 = \(f) => \(o, x) => \(y1, y2, y3, y4, y5) => f (x, y1, y2, y3, y4, y5) + +val test2_2 = print_int (curry_2_2 (f2) (0, 1) (2)) +val test2_3 = print_int (curry_2_3 (f3) (0, 1) (2, 3)) +val test2_4 = print_int (curry_2_4 (f4) (0, 1) (2, 3, 4)) +val test2_5 = print_int (curry_2_5 (f5) (0, 1) (2, 3, 4, 5)) +val test2_6 = print_int (curry_2_6 (f6) (0, 1) (2, 3, 4, 5, 6)) diff --git a/flap/tests/04-Hobix_to_Fopix/10-nesting.expected b/flap/tests/04-Hobix_to_Fopix/10-nesting.expected new file mode 100644 index 0000000..25bf17f --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/10-nesting.expected @@ -0,0 +1 @@ +18 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/10-nesting.hobix b/flap/tests/04-Hobix_to_Fopix/10-nesting.hobix new file mode 100644 index 0000000..72ca837 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/10-nesting.hobix @@ -0,0 +1,9 @@ +val f = \(x) => + val g = \(y) => + (val h = \(z) => + (val i = \(t) => x + y + z + t; + i (z + 1)); + h (y + 1)); + g (x + 1) + +val main = print_int (f (3)) diff --git a/flap/tests/04-Hobix_to_Fopix/11-primitive.expected b/flap/tests/04-Hobix_to_Fopix/11-primitive.expected new file mode 100644 index 0000000..a422342 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/11-primitive.expected @@ -0,0 +1 @@ +4233 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/11-primitive.hobix b/flap/tests/04-Hobix_to_Fopix/11-primitive.hobix new file mode 100644 index 0000000..8c6fdbd --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/11-primitive.hobix @@ -0,0 +1,7 @@ +fun apply (f, x) = f (x) +fun apply2 (f, x, y) = f (x, y) + +val main = + apply (print_int, 42); + apply (print_int, (apply2 (`+`, 31, 2))) + diff --git a/flap/tests/04-Hobix_to_Fopix/12-nested-mutual-recursion.expected b/flap/tests/04-Hobix_to_Fopix/12-nested-mutual-recursion.expected new file mode 100644 index 0000000..4d2b256 --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/12-nested-mutual-recursion.expected @@ -0,0 +1 @@ +2042 \ No newline at end of file diff --git a/flap/tests/04-Hobix_to_Fopix/12-nested-mutual-recursion.hobix b/flap/tests/04-Hobix_to_Fopix/12-nested-mutual-recursion.hobix new file mode 100644 index 0000000..19f3e5f --- /dev/null +++ b/flap/tests/04-Hobix_to_Fopix/12-nested-mutual-recursion.hobix @@ -0,0 +1,14 @@ +fun h (x, y, z) = + fun f (x) = + if x =? 0 then z + else g (x - 1) + fi + and g (x) = + if x =? 0 then y + else f (x - 1) + fi; + g (x) + +val main = + print_int (h (2, 20, 42)); + print_int (h (3, 20, 42)) diff --git a/flap/tests/Makefile b/flap/tests/Makefile index a1adea0..f31f440 100644 --- a/flap/tests/Makefile +++ b/flap/tests/Makefile @@ -3,8 +3,10 @@ JALONS=\ 01-Parsing.results \ 01-Parsing-no-positions.results \ 02-Interpreter.results \ - 03-Typing.results -EXTS=parsing.hopix parsing-no-positions.hopix eval.hopix typing.hopix + 03-Typing.results \ + 04-Hobix_to_Fopix.results +EXTS=parsing.hopix parsing-no-positions.hopix eval.hopix typing.hopix \ + hobix .PHONY: all clean test FAKE .PRECIOUS: %.output %.expected %.score diff --git a/jalon-4.pdf b/jalons/jalon-4.pdf similarity index 100% rename from jalon-4.pdf rename to jalons/jalon-4.pdf