Skip to content

Instantly share code, notes, and snippets.

@xieyuheng
Created November 18, 2015 21:16
Show Gist options
  • Save xieyuheng/d0f1880f3a5b59db17c2 to your computer and use it in GitHub Desktop.
Save xieyuheng/d0f1880f3a5b59db17c2 to your computer and use it in GitHub Desktop.
(letrec ([f (lambda (x) (cons 'a x))]
[g (lambda (x) (cons 'b (f x)))]
[h (lambda (x) (g (cons 'c x)))])
(cons 'd (h '())))
;; (d b a c)
(letrec ([f (lambda (x k) (k (cons 'a x)))]
[g (lambda (x k) (f x (lambda (v) (k (cons 'b v)))))]
[h (lambda (x k) (g (cons 'c x) k))])
(h '() (lambda (v) (cons 'd v))))
* f
+ :x
| 'a :x cons
* g
+ :x
| 'b :x f cons
* h
+ :x
| 'c :x cons g
'd '() h cons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment