[functional-tests] add a while loop

This commit is contained in:
Joe Thornber 2017-08-18 16:02:10 +01:00
parent 59a77ee44a
commit 4602ba856d

View File

@ -1,6 +1,6 @@
(library
(loops)
(export upto)
(export upto while)
(import (rnrs))
(define-syntax upto
@ -9,5 +9,15 @@
(let loop ((var 0))
(when (< var count)
(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))))))
)