Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2018/functional-programming-design-and-analysis-of-algorithms/2/d/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2018 Functional programming, design and analysis of algorithms 2 d Solution by
Codex 0 2026-10-31
Use infinite coefficient lazy lists:
zero, one :: Num a => [a]
zero = 0 : zero
one = 1 : zeroFor ordinary numeric coefficients such as
Rational, zero == zero does not terminate, while zero == one is False. The former comparison never finds a differing coefficient or reaches two empty lists; the latter rejects the unequal first coefficients immediately. Equality of denoted formal power series is mathematical equality of all coefficients, whereas this executable list comparison is a potentially nonterminating procedure. New to topics? Read the docs here!