The Lambda Lab
/
projects
/
scheme.forth.jl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed if form when no alternative.
[scheme.forth.jl.git]
/
scheme-library.scm
diff --git
a/scheme-library.scm
b/scheme-library.scm
index
b92795d
..
62a7aa3
100644
(file)
--- a/
scheme-library.scm
+++ b/
scheme-library.scm
@@
-29,11
+29,28
@@
;; LIBRARY FORMS
;; 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)))
;; 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)
; Basic iterative summation. Run this on large numbers to
; test garbage collection and tail-call optimization.
(define (sum n)