Comp210 Lab 10: More abstract functions, Homework Q&A

Abstract functions, Homework Q&A


Abstract functions

On the current and future homeworks and exam, you are expected to use abstract functions where applicable. We've previously discussed map, filter, foldr, and foldl. Those are entirely sufficient, but today we'll introduce andmap, ormap, and build-list:

     (andmap f (list x1 ... xn)) = (and (f x1) ... (f xn))
     (ormap  f (list x1 ... xn)) = (or  (f x1) ... (f xn))
     (build-list nat f)          = (list (f 0) ... (f (sub1 nat)))
Mainly, we'll get some practice in using them.

To do: Using abstract functions and lambda, write the following functions. All should be very short (2-4 lines each). Many have multiple solutions, even just with the given abstract functions.


Homework Q&A

Come to lab prepared with intelligent homework questions, i.e., something more than "How do you solve part X?".