diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 73edb31a..70a36595 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -212,3 +212,16 @@ (if (compare obj (caar list)) (car list) (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))))