mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-12 16:50:22 +02:00
* boot-9.scm (values, call-with-values): Moved here from
syncase.scm.
This commit is contained in:
parent
ad3ff75be8
commit
1729d8ff31
1 changed files with 25 additions and 0 deletions
|
@ -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}
|
||||
;;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue