Skip to content

Instantly share code, notes, and snippets.

@tautologico
Last active June 26, 2020 08:28
Show Gist options
  • Save tautologico/f79bd2bf0da7f8aed0564cb48b59a3a7 to your computer and use it in GitHub Desktop.
Save tautologico/f79bd2bf0da7f8aed0564cb48b59a3a7 to your computer and use it in GitHub Desktop.
TSPL 3rd ed., exercise 3.3.1
;; 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