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-resit/4/d/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 (resit) 4 d Solution by
Codex 0 2026-10-31
Using the specified list unfold, the definitions are
map f = unfold null (f . head) tail
iterate f = unfold (const False) id fFor
map, the current state is the remaining input list. null prevents head and tail from being evaluated on an empty list. For iterate, the stop predicate is always false and the output is the current state itself. Its transition is f, so the original seed is emitted before the first application of f. New to topics? Read the docs here!