Merge branch 'master' of gaufre.informatique.univ-paris-diderot.fr:aguatto/compilation-m1-2023
This commit is contained in:
commit
c2cdce8baa
27 changed files with 136 additions and 2 deletions
Binary file not shown.
1
flap/tests/04-Hobix_to_Fopix/01-fact.expected
Normal file
1
flap/tests/04-Hobix_to_Fopix/01-fact.expected
Normal file
|
@ -0,0 +1 @@
|
|||
120
|
5
flap/tests/04-Hobix_to_Fopix/01-fact.hobix
Normal file
5
flap/tests/04-Hobix_to_Fopix/01-fact.hobix
Normal file
|
@ -0,0 +1,5 @@
|
|||
fun fact (n) =
|
||||
if n =? 0 then 1 else n * fact (n - 1) fi
|
||||
|
||||
val main =
|
||||
print_int (fact (5))
|
1
flap/tests/04-Hobix_to_Fopix/02-addk.expected
Normal file
1
flap/tests/04-Hobix_to_Fopix/02-addk.expected
Normal file
|
@ -0,0 +1 @@
|
|||
42
|
5
flap/tests/04-Hobix_to_Fopix/02-addk.hobix
Normal file
5
flap/tests/04-Hobix_to_Fopix/02-addk.hobix
Normal file
|
@ -0,0 +1,5 @@
|
|||
fun addk (k) = \(x) => x + k
|
||||
|
||||
val f = addk (41)
|
||||
|
||||
val main = print_int (f (1))
|
1
flap/tests/04-Hobix_to_Fopix/03-apply.expected
Normal file
1
flap/tests/04-Hobix_to_Fopix/03-apply.expected
Normal file
|
@ -0,0 +1 @@
|
|||
42
|
3
flap/tests/04-Hobix_to_Fopix/03-apply.hobix
Normal file
3
flap/tests/04-Hobix_to_Fopix/03-apply.hobix
Normal file
|
@ -0,0 +1,3 @@
|
|||
fun apply (f, x) = f (x)
|
||||
|
||||
val main = apply ((\(x) => print_int (x)), 42)
|
1
flap/tests/04-Hobix_to_Fopix/04-curry.expected
Normal file
1
flap/tests/04-Hobix_to_Fopix/04-curry.expected
Normal file
|
@ -0,0 +1 @@
|
|||
42
|
10
flap/tests/04-Hobix_to_Fopix/04-curry.hobix
Normal file
10
flap/tests/04-Hobix_to_Fopix/04-curry.hobix
Normal file
|
@ -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))
|
|
@ -0,0 +1 @@
|
|||
1
|
10
flap/tests/04-Hobix_to_Fopix/05-mutual-recursion.hobix
Normal file
10
flap/tests/04-Hobix_to_Fopix/05-mutual-recursion.hobix
Normal file
|
@ -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))
|
1
flap/tests/04-Hobix_to_Fopix/06-compose.expected
Normal file
1
flap/tests/04-Hobix_to_Fopix/06-compose.expected
Normal file
|
@ -0,0 +1 @@
|
|||
42424240
|
12
flap/tests/04-Hobix_to_Fopix/06-compose.hobix
Normal file
12
flap/tests/04-Hobix_to_Fopix/06-compose.hobix
Normal file
|
@ -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))
|
|
@ -0,0 +1 @@
|
|||
42
|
|
@ -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))
|
|
@ -0,0 +1 @@
|
|||
85
|
|
@ -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))
|
1
flap/tests/04-Hobix_to_Fopix/09-curryNM.expected
Normal file
1
flap/tests/04-Hobix_to_Fopix/09-curryNM.expected
Normal file
|
@ -0,0 +1 @@
|
|||
3610152136101521
|
29
flap/tests/04-Hobix_to_Fopix/09-curryNM.hobix
Normal file
29
flap/tests/04-Hobix_to_Fopix/09-curryNM.hobix
Normal file
|
@ -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))
|
1
flap/tests/04-Hobix_to_Fopix/10-nesting.expected
Normal file
1
flap/tests/04-Hobix_to_Fopix/10-nesting.expected
Normal file
|
@ -0,0 +1 @@
|
|||
18
|
9
flap/tests/04-Hobix_to_Fopix/10-nesting.hobix
Normal file
9
flap/tests/04-Hobix_to_Fopix/10-nesting.hobix
Normal file
|
@ -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))
|
1
flap/tests/04-Hobix_to_Fopix/11-primitive.expected
Normal file
1
flap/tests/04-Hobix_to_Fopix/11-primitive.expected
Normal file
|
@ -0,0 +1 @@
|
|||
4233
|
7
flap/tests/04-Hobix_to_Fopix/11-primitive.hobix
Normal file
7
flap/tests/04-Hobix_to_Fopix/11-primitive.hobix
Normal file
|
@ -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)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
2042
|
|
@ -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))
|
|
@ -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
|
||||
|
|
Reference in a new issue