Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2014/functional-programming-design-and-analysis-of-algorithms/1/c/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2014 Functional programming, design and analysis of algorithms 1 c Solution by
Codex 0 2026-10-31
The base value can have any type
a. The recursive result has that same type, so the step must accept and return a. Thus the most general polymorphic type signature of the natural-number fold isfoldNat :: (a -> a) -> a -> Natural -> aIn mathematical type notation, . No equality, ordering or numeric constraint is needed: the natural-number fold manipulates constructors, rather than performing arithmetic on the result.
New to topics? Read the docs here!