Last active
August 29, 2015 13:56
-
-
Save alksl/8860410 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
(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