Skip to content

Instantly share code, notes, and snippets.

@wasamasa
Last active May 3, 2020 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wasamasa/6302738ef443f5a9ddb3 to your computer and use it in GitHub Desktop.
Save wasamasa/6302738ef443f5a9ddb3 to your computer and use it in GitHub Desktop.
break, continue
(dotimes (i 10)
(catch 'continue
(when (zerop (% i 2))
(throw 'continue t))
(message "%s" i)))
(let ((i 0))
(catch 'break
(while t
(catch 'continue
(when (zerop (% i 2))
(throw 'continue t))
(message "%s" i))
(when (= i 10)
(throw 'break t))
(setq i (1+ i)))))
(import scheme)
(import (chicken base))
(import (srfi 1))
(let loop ((i 0))
(when (< i 10)
(call-with-current-continuation
(lambda (continue)
(if (zero? (modulo i 2))
(continue #f)
(print i))))
(loop (add1 i))))
(call-with-current-continuation
(lambda (break)
(let loop ((i 0))
(call-with-current-continuation
(lambda (continue)
(if (zero? (modulo i 2))
(continue #f)
(print i))))
(when (= i 10)
(break #f))
(loop (add1 i)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment