]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex4_9.rkt
Merge branch 'master' of github.com:vu3rdd/sicp
[sicp.git] / src / sicp / ex4_9.rkt
1 #lang racket
2
3 ;; 4.9
4 #|
5
6 do, for, while, until, when
7
8 a. for
9
10 (for <var> in <seq>
11   <body>)
12
13 bind var with each value in sequence, execute the <body> and 
14 collect the result of the last expression into a list.
15
16 b. (dotimes n <number>
17      <body>)
18
19 Bind n to the number and execute the body that many times for
20 side effects.
21
22 c. (while <predicate>
23      <body>)
24
25 Check the value of the predicate, if true, execute the body,
26 check the predicate again until it is false, in which case,
27 stop executing the body.
28
29 |#
30
31 #|  implementation:
32
33 Derived expressions can be used to implement all the above 
34 constructs. For example, 'for' can be implementing by transforming
35 the body into an iterative procedure. 'dotimes' is similar and
36 simpler. 'while' can be implemented using recursive procedure
37 and 'if'.
38
39 |#
40