[functional-tests] from-to loop macro
This commit is contained in:
parent
fa8d691744
commit
05151c648c
@ -1,6 +1,6 @@
|
|||||||
(library
|
(library
|
||||||
(loops)
|
(loops)
|
||||||
(export upto while)
|
(export upto from-to while)
|
||||||
(import (rnrs))
|
(import (rnrs))
|
||||||
|
|
||||||
(define-syntax upto
|
(define-syntax upto
|
||||||
@ -11,6 +11,14 @@
|
|||||||
(begin body ...)
|
(begin body ...)
|
||||||
(loop (+ 1 var)))))))
|
(loop (+ 1 var)))))))
|
||||||
|
|
||||||
|
(define-syntax from-to
|
||||||
|
(syntax-rules ()
|
||||||
|
((_ (var f t step) b1 b2 ...)
|
||||||
|
(let loop ((var f))
|
||||||
|
(unless (= var t)
|
||||||
|
b1 b2 ...
|
||||||
|
(loop (+ var step)))))))
|
||||||
|
|
||||||
(define-syntax while
|
(define-syntax while
|
||||||
(syntax-rules ()
|
(syntax-rules ()
|
||||||
((_ (var exp) body ...)
|
((_ (var exp) body ...)
|
||||||
|
Loading…
Reference in New Issue
Block a user