Programming

(Scheme) call/cc

steloflute 2012. 9. 11. 23:30


; Simulating break
(call/cc (lambda (break)
           (for ([x (in-range 0 10)])
             (cond [(= x 5) => (break)])
             (displayln x))))

=>
0
1
2
3
4




http://vijaymathew.wordpress.com/2009/07/22/yaaec-yet-another-attempt-to-explain-continuations/

'Programming' 카테고리의 다른 글

Clojure: The zombie-reanimated corpse of Lisp | imagine27  (0) 2012.09.14
(Racket) (system)  (0) 2012.09.12
(Haskell) Hello World  (0) 2012.09.10
(Racket) file->string  (0) 2012.09.09
Racket define-syntax-rule  (0) 2012.09.08