diff options
Diffstat (limited to 'js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/while.scm')
-rw-r--r-- | js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/while.scm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/while.scm b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/while.scm new file mode 100644 index 0000000..640812b --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/4.2/while.scm @@ -0,0 +1,17 @@ + (define (while a b)(if (a) (begin (force b) (while a b)) 'done)) + + (define (while a b)(if (a) (begin (b) (while a b)) 'done)) + +(let ((x 10)) +(while (lambda() (> x 0)) (lambda()(display x)(set! x (- x 1))))) ;works + + +(define (while a b)(if (a) (begin (b) (while a b))) + + +(let ((x 10)) + (while (delay (> x 0)) + (delay (begin (display x) + (set! x (- x 1)))) + ; does not work because of memoization + )) |