;; LIBRARY FORMS
+(define-macro (while condition . body)
+ `(begin
+ (define (loop)
+ (if ,condition
+ (begin ,@body (loop))))
+ (loop)))
+
;; TESTING
(define-macro (backwards . body)
(cons 'begin (reverse body)))
+(define method '(while (> counter 0)
+ (display counter) (newline)
+ (set! counter (- counter 1))))
+
+(define (count)
+ (define counter 10)
+ (while (> counter 0)
+ (display counter) (newline)
+ (set! counter (- counter 1))))
+
; Basic iterative summation. Run this on large numbers to
; test garbage collection and tail-call optimization.
(define (sum n)
: if-consequent ( ifobj -- conseq )
cdr cdr car ;
-: if-alternative ( ifobj -- alt|false )
+: if-alternative ( ifobj -- alt|none )
cdr cdr cdr
nil? if
- 2drop false
+ 2drop none
else
car
then ;