September 2013
Intermediate to advanced
548 pages
12h 25m
English
Lists are used to store arbitrary numbers of things. We create a list by enclosing the list elements in square brackets and separating them with commas.
Suppose we want to represent a drawing. If we assume that the drawing is made up of triangles and squares, we could represent the drawing as a list.
| | 1> Drawing = [{square,{10,10},10}, {triangle,{15,10},{25,10},{30,40}}, |
| | ...] |
Each of the individual elements in the drawing list are fixed-size tuples (for example, {square, Point, Side} or
{triangle, Point1, Point2, Point3}), but the drawing itself
can contain an arbitrary number of things and so is represented by a list.
The individual elements of a list can be of any type, so, for example, we could write the following:
| | 2> |
Read now
Unlock full access