diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/ackermann.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/ackermann.c b/examples/ackermann.c new file mode 100644 index 0000000..08acd4d --- /dev/null +++ b/examples/ackermann.c @@ -0,0 +1,25 @@ +#include <csxbind.h> +#include <stdio.h> + + +int main() +{ + init(); + char *m = N("m"); + char *n = N("n"); + char *ackermann = N("ackermann"); + printf("%d\n", *(int *)R(L(_do, + L(set, ackermann, L(fn, L(m, n, 0), + L(_if, + L(same, m, I(0), 0), L(_plus, n, I(1), 0), + L(same, n, I(0), 0), L(ackermann, L(_plus, m, I(-1), 0), I(1), 0), + L(ackermann, + L(_plus, m, I(-1), 0), + L(ackermann, m, L(_plus, n, I(-1), 0), 0), + 0), + 0), + 0), 0), + L(ackermann, I(3), I(7), 0), + 0))); + return 0; +} |