values.scm 543 B

12345678910111213141516171819202122
  1. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  2. ; Authors: Richard Kelsey, Jonathan Rees
  3. ; Multiple return values
  4. (define multiple-value-token (vector 'multiple-value-token))
  5. (define (values . things)
  6. (if (and (pair? things)
  7. (null? (cdr things)))
  8. (car things)
  9. (cons multiple-value-token things)))
  10. (define (call-with-values producer consumer)
  11. (let ((things (producer)))
  12. (if (and (pair? things)
  13. (eq? (car things) multiple-value-token))
  14. (apply consumer (cdr things))
  15. (consumer things))))