Procedures as Arguments
Why ‘high order procedures’ is useful?
Often the same programming pattern will be used with a number of different procedures. To express such patterns as concepts, we will need to construct procedures that can accept procedures as arguments or return procedures as values. Procedures that manipulate procedures are called highorder procedures, they can serve as powerful abstraction mechanisms, vastly increaseing the expressive power of our language.
Lambda
 Using lambda to create anonymous functions:
 (define (plus4 x) (+ x 4)) is equivalent to (define plus4 (lambda (x) (+ x 4)))
 Using lambda(let) to create local variables
Sometimes we can use internal definitions to get the same effect as with let.
And in which cases we couldn’t get the same effect?
Abstractions and firstclass procedures
As programmers, we should be alert to oppotunities to identify the underlying abstractions in our programs and to build upon then and generalize them to create more powerful abstractions. This is not to say one should always write programs in the most abstract way possible; expert programmers know how to choose the level of abstraction appropriate to their task. But it’s important to be able to think in terms of these abstractions, so that we can be ready to apply them in new contexts.
Exercises
1.29 Answer:
This is not very hard, just simply translate the simpson rule definition to code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 

1.30 Answer:
Put both the recursive and iterative versions here to compare:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 

They produce the same results as expected.
1.31 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 

There might be better ways to translate the formula. The solution above the is not veru accurate and if the upper bound is too large (say 100), it will yield to ‘nan+’.
1.32 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 

1.33 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 

1.34 Answer:
Apply (f f) with get (f 2), while tring to apply (f 2), error will be issued since a procedure is expected but an integer parameter 2 is given.
1.35 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 

1.36 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 

1.37 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 

1.38 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 

1.39 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 

1.40 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 

1.41 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 

1.42 Answer:
1 2 3 4 5 6 7 8 9 

1.43 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 

1.44 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 

1.45 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 

1.46 Answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 
