Skip to content

Instantly share code, notes, and snippets.

@imphasing
Created November 1, 2011 18:37
Show Gist options
  • Save imphasing/1331483 to your computer and use it in GitHub Desktop.
Save imphasing/1331483 to your computer and use it in GitHub Desktop.
(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