scm.mes: implement do.
This commit is contained in:
parent
746d06a0ec
commit
39d5722973
6
scm.mes
6
scm.mes
|
@ -62,6 +62,12 @@
|
|||
(let-loop ,bindings-or-label ,(car rest) ,(cdr rest)))
|
||||
(#t (simple-let ,bindings-or-label ,rest))))
|
||||
|
||||
(define-macro (do init test . body)
|
||||
`(let loop ((,(caar init) ,(cadar init)))
|
||||
(when (not ,@test)
|
||||
,@body
|
||||
(loop ,@(cddar init)))))
|
||||
|
||||
(define-macro (or2 x y)
|
||||
`(cond (,x ,x) (#t ,y)))
|
||||
|
||||
|
|
2
test.mes
2
test.mes
|
@ -285,6 +285,8 @@
|
|||
(pass-if "min 1" (seq? (min 0 1) 0))
|
||||
(pass-if "min 2" (seq? (min 1 0 2) 0))
|
||||
|
||||
(pass-if "do" (sequal? (let ((acc '())) (do ((i 0 (+ i 1))) ((>= i 3)) (set! acc (cons i acc))) acc) '(2 1 0)))
|
||||
|
||||
(newline)
|
||||
(display "passed: ") (display (car (result))) (newline)
|
||||
(display "failed: ") (display (cadr (result))) (newline)
|
||||
|
|
Loading…
Reference in a new issue