aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/fib.c50
-rw-r--r--examples/generated.c2
-rw-r--r--examples/generated.csx8
-rw-r--r--examples/translator.c4
4 files changed, 6 insertions, 58 deletions
diff --git a/examples/fib.c b/examples/fib.c
deleted file mode 100644
index fc03fbb..0000000
--- a/examples/fib.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <csx.h>
-#include <stdio.h>
-
-
-static csx_list_fn *l;
-static csx_num_fn *n;
-
-char *define;
-char *fn;
-char *pair;
-char *head;
-char *tail;
-char *not;
-char *csx_if;
-char *inc;
-char *sum;
-char *diff;
-
-void process()
-{
- char *fib = csx_name("fib");
- char *num = csx_name("num");
- csx_eval(l(define, fib, l(fn, l(num, 0),
- l(csx_if, l(inc, num, n(3), 0), n(1),
- l(sum,
- l(fib, l(diff, num, n(1), 0), 0),
- l(fib, l(diff, num, n(2), 0), 0),
- 0),
- 0),
- 0), 0));
- printf("fib 6 = %d\n", *(int *)csx_eval(l(fib, n(6), 0)));
-}
-
-int main()
-{
- l = csx_list;
- n = csx_num;
- define = csx_name("define");
- fn = csx_name("fn");
- pair = csx_name("pair");
- head = csx_name("head");
- tail = csx_name("tail");
- not = csx_name("not");
- csx_if = csx_name("if");
- inc = csx_name("inc");
- sum = csx_name("sum");
- diff = csx_name("diff");
- process();
- return 0;
-}
diff --git a/examples/generated.c b/examples/generated.c
index caa11e2..db94cc6 100644
--- a/examples/generated.c
+++ b/examples/generated.c
@@ -1,6 +1,6 @@
#include <csx.h>
int main()
{
-csx_eval(csx_list(csx_name("do"),csx_list(csx_name("define"),csx_name("map"),csx_list(csx_name("fn"),csx_list(csx_name("f"),csx_name("l"),0),csx_list(csx_name("if"),csx_list(csx_name("not"),csx_name("l"),0),csx_list(0),csx_list(csx_name("pair"),csx_list(csx_name("f"),csx_list(csx_name("head"),csx_name("l"),0),0),csx_list(csx_name("map"),csx_name("f"),csx_list(csx_name("tail"),csx_name("l"),0),0),0),0),0),0),csx_list(csx_name("map"),csx_list(csx_name("fn"),csx_list(csx_name("n"),0),csx_list(csx_name("outnum"),csx_name("n"),0),csx_list(csx_name("output"),csx_num(10),0),0),csx_list(csx_name("map"),csx_list(csx_name("fn"),csx_list(csx_name("n"),0),csx_list(csx_name("sum"),csx_name("n"),csx_num(10),0),0),csx_list(csx_name("quote"),csx_list(csx_num(1),csx_num(2),csx_num(3),csx_num(4),csx_num(5),0),0),0),0),0));
+csx_run(csx_list(csx_name("do"),csx_list(csx_name("set"),csx_name("map"),csx_list(csx_name("fn"),csx_list(csx_name("f"),csx_name("l"),0),csx_list(csx_name("if"),csx_list(csx_name("same"),csx_name("l"),csx_list(0),0),csx_list(0),csx_list(csx_name("pair"),csx_list(csx_name("f"),csx_list(csx_name("head"),csx_name("l"),0),0),csx_list(csx_name("map"),csx_name("f"),csx_list(csx_name("tail"),csx_name("l"),0),0),0),0),0),0),csx_list(csx_name("map"),csx_list(csx_name("fn"),csx_list(csx_name("n"),0),csx_list(csx_name("sum"),csx_name("n"),csx_int(10),0),0),csx_list(csx_name("quote"),csx_list(csx_int(1),csx_int(2),csx_int(3),csx_int(4),csx_int(5),0),0),0),0));
return 0;
}
diff --git a/examples/generated.csx b/examples/generated.csx
index 4d22565..bddb2ed 100644
--- a/examples/generated.csx
+++ b/examples/generated.csx
@@ -1,9 +1,7 @@
-[define map [fn [f l] [if [not l] []
+[set map [fn [f l] [if [same l []] []
[pair [f [head l]] [map f [tail l]]]
]]]
-[map [fn [n] [outnum n] [output 10]]
- [map [fn [n] [sum n 10]]
- [quote [1 2 3 4 5]]
- ]
+[map [fn [n] [sum n 10]]
+ [quote [1 2 3 4 5]]
]
diff --git a/examples/translator.c b/examples/translator.c
index ad676c0..14b7482 100644
--- a/examples/translator.c
+++ b/examples/translator.c
@@ -17,7 +17,7 @@ void readlist()
} else if (isdigit(c) || c == '-') {
if (first) first = 0;
else putchar(',');
- printf("csx_num(");
+ printf("csx_int(");
putchar(c);
c = getchar();
while (c != EOF && isdigit(c)) {
@@ -47,7 +47,7 @@ int main()
puts("#include <csx.h>");
puts("int main()");
puts("{");
- printf("csx_eval(csx_list(csx_name(\"do\"),");
+ printf("csx_run(csx_list(csx_name(\"do\"),");
readlist();
puts("0));");
puts("return 0;");