Why doesn't this while loop work for the metacircular interpreter. How do i run this in my interactions window ?
((while? exp) (eval (while->combination exp) env))
(define (while-condition expr) (cadr expr))
(define (while-body expr) (caddr expr))
(define (while->combination exp)
(sequence->exp
(list (list 'define
(list 'while-iter)
(make-if (while-condition exp)
(sequence->exp (list (while-body exp)
(list 'while-iter)))
'true))
(list 'while-iter))))
To answer this I have used the metacircular evaluator described in SICP 4.1.1 since your code lacked some procedures in order to run.
So if you have a test form like
(while (call-something) (do-something-1) (do-something-2)))
you can send it quoted towhile->combination
like this:If you are using DrRacket you can just put the same at the end of the definitions window and hit Debug >| and step through your code easily.
The output I'm getting from running this is: