diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2021-01-03 02:01:27 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2021-01-03 02:01:27 +0300 |
commit | fdb7b619342067116618abd68f83dd7ff1b0e033 (patch) | |
tree | 8937c7f9f7adc9c23cb66346c39120b66d0135e7 | |
parent | abfe132b83219efa30220ecfdaf6e26e31b9d13d (diff) | |
download | csx-fdb7b619342067116618abd68f83dd7ff1b0e033.tar csx-fdb7b619342067116618abd68f83dd7ff1b0e033.tar.xz csx-fdb7b619342067116618abd68f83dd7ff1b0e033.zip |
More complex examples of CSX syntax.
-rw-r--r-- | examples/generated.c | 2 | ||||
-rw-r--r-- | examples/generated.csx | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/examples/generated.c b/examples/generated.c index 0b70fd6..caa11e2 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("a"),csx_num(10),0),csx_list(csx_name("define"),csx_name("b"),csx_list(csx_name("sum"),csx_name("a"),csx_num(3),0),0),csx_list(csx_name("outname"),csx_list(csx_name("quote"),csx_name("sum-of-10-and-3-is"),0),0),csx_list(csx_name("outnum"),csx_name("b"),0),0)); +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)); return 0; } diff --git a/examples/generated.csx b/examples/generated.csx new file mode 100644 index 0000000..4d22565 --- /dev/null +++ b/examples/generated.csx @@ -0,0 +1,9 @@ +[define map [fn [f l] [if [not 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]] + ] +] |