Skip to content

Instantly share code, notes, and snippets.

@samth
Created March 5, 2012 20:49
Show Gist options
  • Select an option

  • Save samth/1980985 to your computer and use it in GitHub Desktop.

Select an option

Save samth/1980985 to your computer and use it in GitHub Desktop.
delay/values
#lang racket/base
(require racket/promise)
(provide delay/values)
(define-syntax-rule (delay/values n . e)
(let ([tmp (lazy (call-with-values (λ () . e) vector))])
(apply values (for/list ([i (in-range n)])
(lazy (vector-ref (force tmp) i))))))
(define-values (x y)
(delay/values 2 (printf "wheee\n") (values 1 2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment