add values/call-with-values
This commit is contained in:
parent
4fea9169cc
commit
901cf0ed09
|
@ -212,3 +212,16 @@
|
||||||
(if (compare obj (caar list))
|
(if (compare obj (caar list))
|
||||||
(car list)
|
(car list)
|
||||||
(assoc obj (cdr list) compare)))))
|
(assoc obj (cdr list) compare)))))
|
||||||
|
|
||||||
|
(define (values . args)
|
||||||
|
(if (and (pair? args)
|
||||||
|
(null? (cdr args)))
|
||||||
|
(car args)
|
||||||
|
(cons '*values-tag* args)))
|
||||||
|
|
||||||
|
(define (call-with-values producer consumer)
|
||||||
|
(let ((res (producer)))
|
||||||
|
(if (and (pair? res)
|
||||||
|
(eq? '*values-tag* (car res)))
|
||||||
|
(apply consumer (cdr res))
|
||||||
|
(consumer res))))
|
||||||
|
|
Loading…
Reference in New Issue