Revision as of 11:55, 8 November 2006 by Lemming
We are used to the list notation
. However it is syntactic sugar for
By using the syntactic sugar, we often miss the benefits of the direct notation.
- A trailing colon is like a terminator.
0 : 1 : 2 : 3 : 
- Thus it is more theoretically sound and easier to edit.
- You can easily mix elements and lists into a list by appending the corresponding operator in each line:
[1,2,3] ++ 4 : listA ++ 5 : listB ++ 
- You can construct a singleton list with a section of the colon operator: .
(:) :: a -> [a]
- You can prepend an element to a list: . E.g.
(x:) :: [a] -> [a]creates a list of blank strings with increasing size very efficiently.
iterate (' ':)