Lab 8: Practice with Abstraction

Important Note: Whenever you abstract from concrete things, remember to re-define them using the new abstraction. They should have the same signatures and purpose statements as before as well as pass the same tests as before. (Helpers are often useful for eliminating inessential differences among concrete things.) The new abstraction should have its own signature and purpose statement. If the original tests do not provide sufficient coverage for the abstraction, include additional tests.

Exercise 1 Abstract from the following functions:

Exercise 2 Abstract from init-x-vel and init-y-vel in Assignment 2.

Exercise 3 Abstract from the functions weight and all-balanced? in Assignment 7 (Exercises 7 and 9). Optional: abstract as well from the "helper function that also takes a Mobile as input" in Exercise 8 in Assignment 7.

Note: Although the Intermediate Student Language allows passing functions as inputs to other functions, it doesn’t allow passing and and or as inputs to other functions. To work around this restriction, you may need to define your own helper function which is just a thin wrapper around and.

Exercise 4 Abstract from the following functions:

Exercise 5 Do book exercise 239 in How to Design Programs, Second Edition (Draft).

Exercise 6 Abstract from the following functions:

Extra fun: instead of abstracting from these functions, can you define them using the function from class called math or op-lon? How about using the built-in functions foldl or foldr?