Counting the number of Elements in a List

The empty list has zero elements. The list x::m has one more element than the list m. So:
length: list(alpha) -> num;
length [ ] <= 0;
length (x::m) <= 1 + length(m);
Notice length takes a list (alpha), i.e. a list of any type. Since counting the elements of a list of any type is the same.
Sebastian Danicic BSc MSc PhD (Reader in Computer Science)
Dept of Computing, Goldsmiths, University of London, London SE14 6NW
Last updated 2010-12-29