Skip to content

Instantly share code, notes, and snippets.

@stibear
Created May 19, 2014 17:14
Show Gist options
  • Save stibear/2fd11f33560c485f01aa to your computer and use it in GitHub Desktop.
Save stibear/2fd11f33560c485f01aa to your computer and use it in GitHub Desktop.
(import (scheme lazy)
(picrin macro))
(define-syntax delay/cc
(syntax-rules ()
((delay/cc expr)
(lambda (k) (k expr)))))
(define-syntax force/cc
(syntax-rules ()
((force/cc expr)
(call/cc expr))))
(define pr1 (delay (+ 1 2)))
(define pr2 (delay/cc (+ 1 2)))
(= (+ 3 (force pr1)) (+ 3 (force/cc pr2)))
; => #t
(macroexpand '(force/cc (delay/cc (+ 1 2))))
; => (call/cc@142 (lambda (k@1744) (k@1744 (+@77 1 2))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment