Skip to content

Instantly share code, notes, and snippets.

@alksl
Last active August 29, 2015 13:56
Show Gist options
  • Save alksl/8860410 to your computer and use it in GitHub Desktop.
Save alksl/8860410 to your computer and use it in GitHub Desktop.
(define (eval-dolist exp env)
(let ((lst (eval (dolist-listexpr exp env))) ; evaluate the list
(startval (eval (dolist-resultvar exp env)))) ;evaluate the resultvar
(define (dolist-iteration lst result)
(if (null? lst)
result
(dolist-iteration
(rest lst)
(apply-%scheme
(eval-%scheme (make-lambda (list (dolist-variable exp) lst (dolist-resultvar exp))
(append (dolist-body exp) (list (dolist-resultvar exp)))))
(list (first lst) result)))))
(dolist-iteration lst startval)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment