redefine shift and reset as syntaxes

This commit is contained in:
Yuichi Nishiwaki 2015-07-18 15:39:34 +09:00
parent b7bb3fa1cf
commit 3d170afac8
2 changed files with 15 additions and 6 deletions

View File

@ -27,6 +27,16 @@
(reset (lambda () (reset (lambda ()
(k v)))))))))) (k v))))))))))
(export shift (define-syntax reset*
reset)) (syntax-rules ()
((_ expr ...)
(reset (lambda () expr ...)))))
(define-syntax shift*
(syntax-rules ()
((_ k expr ...)
(shift (lambda (k) expr ...)))))
(export (rename shift* shift)
(rename reset* reset)))

View File

@ -4,12 +4,11 @@
(define-syntax for (define-syntax for
(syntax-rules () (syntax-rules ()
((_ expr) ((_ expr ...)
(reset (lambda () expr))))) (reset expr ...))))
(define (in m) (define (in m)
(shift (lambda (k) (shift k (apply append (map k m))))
(apply append (map k m)))))
(define (yield x) (define (yield x)
(list x)) (list x))