diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-01-31 18:47:46 +0200 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-01-31 18:47:46 +0200 |
commit | 4c4df6613e2f96e384615ec1c1bcc0df53fa5bc8 (patch) | |
tree | 0cc5c2ef81bc70d861581ed750935bd9766eb7be | |
parent | aac24c2c43a8047ceb41f1b34336ba2ed8064569 (diff) | |
download | lyn-master.tar.gz lyn-master.zip |
-rw-r--r-- | examples/fib.lyn | 12 | ||||
-rw-r--r-- | src/lyn.c | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/examples/fib.lyn b/examples/fib.lyn new file mode 100644 index 0000000..b24f18b --- /dev/null +++ b/examples/fib.lyn @@ -0,0 +1,12 @@ +define (fib n) { + if (< n 2) { + get 1 + } { + define f1 (fib (- n 1)) + define f2 (fib (- n 2)) + + f1 f2 + } +} + +display (fib 42) +newline @@ -13,7 +13,7 @@ static int eval_group(struct lyn *lyn, struct lyn_value value) { - fprintf(lyn->output, "(begin"); + fprintf(lyn->output, "((lambda () (begin"); lyn->depth++; foreach_vec(gi, value.args) { @@ -24,7 +24,7 @@ static int eval_group(struct lyn *lyn, struct lyn_value value) fprintf(lyn->output, ")"); } - fprintf(lyn->output, "\n%*s)", 2 * lyn->depth, " "); + fprintf(lyn->output, "\n%*s)))", 2 * lyn->depth, " "); lyn->depth--; return 0; |