From 1729d8ff31a255eba2cc845d6875dcbdbb963156 Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Tue, 10 Nov 1998 14:40:28 +0000 Subject: [PATCH] * boot-9.scm (values, call-with-values): Moved here from syncase.scm. --- ice-9/boot-9.scm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index ef63d6ded..31909fe3d 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -493,6 +493,31 @@ (loop (cons init answer) (- n 1))))) + +;;; {Multiple return values} + +(define *values-rtd* + (make-record-type "values" + '(values))) + +(define values + (let ((make-values (record-constructor *values-rtd*))) + (lambda x + (if (and (not (null? x)) + (null? (cdr x))) + (car x) + (make-values x))))) + +(define call-with-values + (let ((access-values (record-accessor *values-rtd* 'values)) + (values-predicate? (record-predicate *values-rtd*))) + (lambda (producer consumer) + (let ((result (producer))) + (if (values-predicate? result) + (apply consumer (access-values result)) + (consumer result)))))) + + ;;; {and-map, or-map, and map-in-order} ;;;