Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2006/ia/paper-5/1/b/solution

A Standard ML length function visits each list constructor once:
sml
fun length [] = 0
  | length (_ :: xs) = 1 + length xs;
Writing for its time complexity, and . Thus . Arithmetic is treated as unit cost; the example concerns list traversal rather than arbitrary-precision arithmetic.

New to topics? Read the docs here!