Created
July 30, 2011 01:39
-
-
Save shirok/1115091 to your computer and use it in GitHub Desktop.
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
gosh> (define-syntax for | |
(syntax-rules (in do) | |
((for var in lis do expr ...) | |
(let loop ((xs lis)) | |
(if (not (null? xs)) | |
(begin (let ((var (car xs))) expr ...) | |
(loop (cdr xs)))))))) | |
#<undef> | |
gosh> (for x in '(1 2 3 4 5) do (print (* x x))) | |
1 | |
4 | |
9 | |
16 | |
25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment