diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2021-03-27 11:48:57 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2021-03-27 11:48:57 +0300 |
commit | df110a9bee56548770a7256845e0d1b84a959972 (patch) | |
tree | 431bc78354e1ab264922e0c2c6419405a4227083 | |
parent | 860b7939b067102e01acbad9ef3effd48b4bf5af (diff) | |
download | csx-df110a9bee56548770a7256845e0d1b84a959972.tar csx-df110a9bee56548770a7256845e0d1b84a959972.tar.xz csx-df110a9bee56548770a7256845e0d1b84a959972.zip |
Ackermann function example added.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | examples/ackermann.c | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build 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; +} |