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/ii/solution

A matching mother or father field identifies a child. In Haskell:
children :: Database -> Person -> [Person]
children db p = unique [baby | (baby,mother,father) <- db,
                              mother == p || father == p]
Duplicate removal handles repeated certificates and children recorded in more than one matching row. Thus
The displayed set describes membership; the implementation returns its entries as a list in first certificate order.

New to topics? Read the docs here!