Last active
May 3, 2020 15:46
-
-
Save wasamasa/6302738ef443f5a9ddb3 to your computer and use it in GitHub Desktop.
break, continue
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
(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))))) |
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
(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