mirror of
https://github.com/anoma/juvix.git
synced 2024-11-30 14:13:27 +03:00
f2298bd674
An implementation of the translation from JuvixCore to JuvixAsm. After merging this PR, the only remaining step to complete the basic compilation pipeline (#1556) is the compilation of complex pattern matching (#1531). * Fixes several bugs in lambda-lifting. * Fixes several bugs in the RemoveTypeArgs transformation. * Fixes several bugs in the TopEtaExpand transformation. * Adds the ConvertBuiltinTypes transformation which converts the builtin bool inductive type to Core primitive bool. * Adds the `juvix dev core strip` command. * Adds the `juvix dev core asm` command. * Adds the `juvix dev core compile` command. * Adds two groups of tests: - JuvixCore to JuvixAsm translation: translate JuvixCore tests to JuvixAsm and run the results with the JuvixAsm interpreter, - JuvixCore compilation: compile JuvixCore tests to native code and WASM and execute the results. * Closes #1520 * Closes #1549
26 lines
480 B
Plaintext
26 lines
480 B
Plaintext
-- Ackermann function (higher-order definition)
|
|
|
|
def compose := \f \g \x g (f x);
|
|
|
|
def iterate := \f \n
|
|
if n = 0 then
|
|
\x x
|
|
else
|
|
compose f (iterate f (n - 1));
|
|
|
|
def plus := iterate (+ 1);
|
|
|
|
def mult := \m \n iterate (plus n) m 0;
|
|
|
|
def exp := \m \n iterate (mult m) n 1;
|
|
|
|
def ackermann := \m
|
|
iterate (\f \n iterate f (n + 1) 1) m (+ 1);
|
|
|
|
def writeLn := \x write x >> write "\n";
|
|
|
|
writeLn (plus 3 7) >>
|
|
writeLn (mult 3 7) >>
|
|
writeLn (exp 3 7) >>
|
|
writeLn (ackermann 3 4)
|