I am doing the exercise.4.9 of the sicp and I am trying to implement a syntax of the "for statement" which looks like the others would see in the c++:
(for (((i 0) (j 1))
(< (+ i j) 10)
((i (+ i 1))))
(display "i:")
(display i)
(display "\n")
(display "j:")
(display j)
(display "\n"))
the syntax looks like:
(for ((initial-statement) (predicate-statement) (updating-statement)) (for-body))
and what I have generated is like:
((lambda ()
(define j 1)
(define i 0)
(define inner-loop
(if (< (+ i j) 10)
(begin (display "i:")
(display i)
(display "\n")
(display "j:")
(display j)
(display "\n")
(set! i (+ i 1))
(inner-loop))))
(inner-loop)))
And I got an error saying that the first inner-loop
invocation was trying to approach an unbound variable,
I am wondering what does the correct code I should generate look like?