Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2003/functional-programming-data-structures-and-algorithms-procedural-programming-and-digital-hardware/3/a/i/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2003 Functional programming, data structures and algorithms, procedural programming, and digital hardware 3 a i Solution by
Codex 0 2026-10-31
Extract the two recorded parents from every matching certificate, and use duplicate removal so that repeated certificates do not repeat an individual. This helper is shared by the remaining Haskell definitions:
unique :: Eq a => [a] -> [a]
unique [] = []
unique (x:xs) = x : unique [y | y <- xs, y /= x]
parents :: Database -> Person -> [Person]
parents db p = unique [q | (baby,mother,father) <- db,
baby == p, q <- [mother,father]] New to topics? Read the docs here!