Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Dynamic wind & call/cc
#lang racket
(define k1 #f)
(define k2 #f)
(lambda ()
;; this dw will only run twice and not three for
;; the initial run, k1, and then k2
(lambda () (displayln "pre1"))
(lambda ()
;; create an application in continuation
(lambda (k)
(set! k1 k)
(lambda (k)
(set! k2 k)
;; identity function for first run
(lambda (x) x)))))
;; returned in first run
;; sent to k2 after invocation of k1
(lambda (x) 5)))
(lambda () (displayln "post1")))))
;; invoke k1 and then invoke k2
(lambda () (k1 k2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.