Created
March 5, 2012 20:49
-
-
Save samth/1980985 to your computer and use it in GitHub Desktop.
delay/values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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