Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2021/functional-programming-design-and-analysis-of-algorithms-resit/3/a/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2021 Functional programming, design and analysis of algorithms (resit) 3 a Solution by
Codex 0 2026-10-25
The empty family has one choice, the empty selection:A selection from the whole family consists uniquely of a choice from its first member and a selection from the remaining family. This bijection proves the combining equation and completeness by induction. If a member family is empty, there are no selections. The base is
cp :: [[a]] -> [[a]]
cp = foldr extend [[]]
where
extend choices suffixes = [x:ys | x <- choices, ys <- suffixes][[]], not []: otherwise every Cartesian product would incorrectly be empty. New to topics? Read the docs here!