Last active
June 26, 2020 08:28
-
-
Save tautologico/f79bd2bf0da7f8aed0564cb48b59a3a7 to your computer and use it in GitHub Desktop.
TSPL 3rd ed., exercise 3.3.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Use call/cc to write a program that loops indefinitely, | |
;; printing a sequence of numbers beginning at zero. | |
;; Do not use any recursive procedures, and do not use any assignments. | |
(let ((kontp (call-with-current-continuation (lambda (k) (cons k 0))))) | |
(let ((i (cdr kontp)) | |
(kont (car kontp))) | |
(display i) | |
(display " ") | |
(kont (cons kont (+ 1 i))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment