6.001, Spring 2005—Recitation 7 16.001—Structure and Interpretation of Computer ProgramsSpring 2005Recitation 7Types and higher-order proceduresTypesTypes can look like this:• Basic types: Number, Boolean, String...• Variable types: A, B, C... can represent any type, but they’re the same type each time• Procedures: for example, (N umber, Number → Number), (A → A), (Number → Boolean)...• Compound types: P air < A, B > or List < A >Problems1. What is the type of cons?2. What is a more specific type of cons, when we use it to adjoin an element to a list?3. What is the type of map?4. What is the type of filter?5. What is the type of accumulate?Higher-order procedures1. Let’s write a procedure, twice, that takes any one-argument procedure and returns a newprocedure that does it twice. For example, (twice square) is a procedure that raises thingsto the fourth power, so ((twice square) 3) is 81.6.001, Spring 2005—Recitation 7 22. What is the type of twice?3. Write thrice.4. What is the type of thrice?5. What should we call (twice thrice)? Is it the sam e as (thrice twice)?6. How is ((twice thrice) f) different from (twice (thrice f))?7. What are we reimplementing?8. Is that cool or
View Full Document