source-academy/js-slang

call/cc or call-with-current-continuation is undefined in Full Scheme

Closed this issue · 1 comments

call-with-current-continuation or call/cc is a pretty nice control-flow operator that is used in CS2104. I was wondering if we could add it to Full Scheme?

https://en.wikipedia.org/wiki/Call-with-current-continuation

Hmm actually, I realised you can just define it easily for the Wikipedia example:

(define (f return)                                                                                                                               
  (return 2)                                                                                                                                     
  3)

(f (lambda (x) x))

(define (call/cc fun)                                                                                                                               
  (fun (lambda (x) (lambda (y) y)))
)

(call/cc f)