[functional-tests] add a while loop
This commit is contained in:
parent
59a77ee44a
commit
4602ba856d
@ -1,6 +1,6 @@
|
|||||||
(library
|
(library
|
||||||
(loops)
|
(loops)
|
||||||
(export upto)
|
(export upto while)
|
||||||
(import (rnrs))
|
(import (rnrs))
|
||||||
|
|
||||||
(define-syntax upto
|
(define-syntax upto
|
||||||
@ -9,5 +9,15 @@
|
|||||||
(let loop ((var 0))
|
(let loop ((var 0))
|
||||||
(when (< var count)
|
(when (< var count)
|
||||||
(begin body ...)
|
(begin body ...)
|
||||||
(loop (+ 1 var))))))))
|
(loop (+ 1 var)))))))
|
||||||
|
|
||||||
|
(define-syntax while
|
||||||
|
(syntax-rules ()
|
||||||
|
((_ (var exp) body ...)
|
||||||
|
(let loop ((var exp))
|
||||||
|
(when var
|
||||||
|
(begin body ...)
|
||||||
|
(loop exp))))))
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user