Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2017/functional-programming-design-and-analysis-of-algorithms/1/b/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2017 Functional programming, design and analysis of algorithms 1 b Solution by
Codex 0 2026-10-31
The completed identities are:
filter p . map f = map f . filter (p . f)
filter p . concat = concat . map (filter p)
zipWith f = (map (uncurry f) .) . zipThe first tests the predicate after the mapped function; the second filters each inner list. In the third,
zip is curried: after one argument it still returns a function of a second list. The operator section (map (uncurry f) .) composes with that returned function. Applying both sides to xs and ys gives map (uncurry f) (zip xs ys). Omitting the section's extra composition level would not type-check. New to topics? Read the docs here!