Created
September 14, 2024 03:00
-
-
Save noqisofon/97c5e16a1692ca7d8de902e6a3cd342c to your computer and use it in GitHub Desktop.
( ノ╹◡◡╹)ノ くりかえしまくろ~~~~
This file contains 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
(include "./reiteration.scm") | |
(dolist (i '(0 1 2 3 4 5 6 7 8 9)) | |
(display i) | |
(display " ")) |
This file contains 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
(define-syntax dolist | |
(syntax-rules () | |
((_ (it seq result) body ...) | |
(let loop ((xs seq)) | |
(if (null? xs) | |
result | |
(begin | |
(let ((it (car xs))) | |
body | |
...) | |
(loop (cdr xs)))))) | |
((_ (it seq) body ...) | |
(let loop ((xs seq)) | |
(if (null? xs) | |
'() | |
(begin | |
(let ((it (car xs))) | |
body | |
...) | |
(loop (cdr xs)))))) | |
((_ (seq) body ...) | |
(let loop ((xs seq)) | |
(if (null? xs) | |
'() | |
(begin | |
body | |
... | |
(loop (cdr xs)))))))) | |
(define-syntax dotimes | |
(syntax-rules () | |
((_ (it num-expr) body ...) | |
(let loop ((n 0)) | |
(if (< num-expr n) | |
'() | |
(begin | |
(let ((it n)) | |
body | |
...) | |
(loop (+ n 1)))))) | |
((_ (num-expr) body ...) | |
(let loop ((n 0)) | |
(if (< num-expr n) | |
'() | |
(begin | |
body | |
... | |
(loop (+ n 1)))))))) | |
(define-syntax while | |
(syntax-rules () | |
((_ expr body ...) | |
(let loop () | |
(if expr | |
(begin | |
body | |
... | |
(loop)) | |
'()))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment