Stoffel

Untitled

Feb 21st, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.50 KB | None | 0 0
  1. (define call/cc call-with-current-continuation)
  2.  
  3. (define (infinite-loop proc)
  4.   (proc)
  5.   (infinite-loop proc))
  6.  
  7. (define (count-to-n n)
  8.   (call/cc (lambda (stop)
  9.              (let ((count 0))
  10.                (infinite-loop (lambda ()
  11.                                 (if (> count n)
  12.                                     (stop)
  13.                                     (begin (display count)
  14.                                            (set! count (+ 1 count))
  15.                                            ))))))))
Advertisement
Add Comment
Please, Sign In to add comment