aboutsummaryrefslogtreecommitdiff
path: root/examples/ackermann.c
blob: d778c8ca13bed9e50cadcd89d8d220f9c275ec6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <csxbind.h>
#include <stdio.h>


int main()
{
    char *m;
    char *n;
    char *ackermann;
    csxbind_init();
    m = N("m");
    n = N("n");
    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(3), 0),
    0)));
    csxbind_free();
    return 0;
}