Uses of lists


next up previous contents
Next: Lists for parse trees
Up: Introduction to Prolog for Mathematicians
Previous: Another example of list processing

Uses of lists

Lists can be used to represent sets. They can also be used to represent trees:

[ plus, a, b ].

[ plus, [times,a,b], [times,c,d] ].

Above, we use them to represent expressions built up from the operators plus and times. If these operators are commutative, it is often convenient to give them more than two arguments:

[ plus, a, b, c, d ].
instead of
[ plus, [ plus, a, b ], [ plus, c, d ] ].

Many algebra-manipulation programs use this method.



Jocelyn Ireson-Ireson-Paine
Mon Jul 17 22:27:41 BST 1995