Created
November 1, 2011 18:37
-
-
Save imphasing/1331483 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
(define-macro (do init test . expr) | |
(let ((bindings (map (lambda (x) (cons (car x) (list (cadr x)))) init)) | |
(steps (map (lambda (x) (if (< 2 (length x)) (caddr x) (car x))) init)) | |
(condition (car test)) | |
(endresult (cdr test)) | |
(loop-name (gensym))) | |
`(let ,loop-name ,bindings | |
(if (not ,condition) | |
(begin ,(car expr) ,(cons loop-name steps)) | |
,@endresult)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment