values.scm 514 B

1234567891011121314151617181920
  1. ; Copyright (c) 1993-2008 by Richard Kelsey and Jonathan Rees. See file COPYING.
  2. ; Multiple return values
  3. (define multiple-value-token (vector 'multiple-value-token))
  4. (define (values . things)
  5. (if (and (pair? things)
  6. (null? (cdr things)))
  7. (car things)
  8. (cons multiple-value-token things)))
  9. (define (call-with-values producer consumer)
  10. (let ((things (producer)))
  11. (if (and (pair? things)
  12. (eq? (car things) multiple-value-token))
  13. (apply consumer (cdr things))
  14. (consumer things))))