diff options
Diffstat (limited to 'examples/guile.lyn')
-rw-r--r-- | examples/guile.lyn | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/guile.lyn b/examples/guile.lyn new file mode 100644 index 0000000..9d7f445 --- /dev/null +++ b/examples/guile.lyn @@ -0,0 +1,18 @@ +define-syntax-rule (for init condition post body) { + expand init + do () ((not (expand condition))) { + expand body + expand post + } +} + +define (sum n) { + define s 0 + for (define i 0) (< i n) (set! i (1+ i)) { + set! s (+ s i) + } + get s +} + +display (sum 1000000) +newline |