I am trying to create my own while-loop in racket using the "define-syntax-rule". I want it to be procedural based, so no helper functions (i.e. just using lambda, let, letrec, etc.).
I have this, but it gives me some sort of lambda identifier error.
(define-syntax-rule (while condition body)
(lambda (iterate)
(lambda (condition body) ( (if condition)
body
iterate))))
I want it to be so I can use it like a regular while loop For Example:
(while (x < 10) (+ x 1))
Calling this will(should) return 10 after the loop is done.
How can my code be fixed to do this?
Here is the
whilefrom my Standard Prelude, along with an example of its use:You should probably talk to your instructor about your misconceptions involving Scheme.