SICP Exercise 4.9 do for while until
Exercise 4.9. Many languages support a variety of iteration constructs, such as do , for , while , and until . In Scheme, iterative processes can be expressed in terms of ordinary procedure calls, so special iteration constructs provide no essential gain in computational power. On the other hand, such constructs are often convenient. Design some iteration constructs, give examples of their use, and show how to implement them as derived expressions. SOLUTION The code and tests are here . I have implemented the following expressions: do-while do-until for while The 'do-while' construct can be as follows: (do (<one or more statements>) while (condition) ) Use the while block construct to convert it as follows: (begin <statements> (while (condition) <statements> ) ) The 'do-until' construct can be as follows: (do (<one or more statements>) ...