![]() |
|
Navigation |
Synopsis An ordered sequence of values.
Description A list is a sequence of values with the following properties:
ELEM (elements) and LIST (lists) and the functions:
nil : -> LIST cons: ELEM x LIST -> LIST head: LIST -> ELEM tail: LIST -> LIST nil and cons are so-called constructor functions that define the values in LIST . They can be paraphrased as:
head (take the first element) and tail (take the remainder of a list)
are defined functions characterized by the axioms:
head(cons(e, l)) = e tail(cons(e, l)) = lThe cases head(nil) and tail(nil) are left undefined (and usually correspond to a runtime error in a programming language).
In Rascal, lists are surrounded by brackets [ and ] and the elements are separated by commas.
Each list has a type of the form list[T] , where T is the smallest common type of all list elements.
See Rascal:Values/List for a description of lists and their operators
and Rascal:Prelude/List for functions on lists.
Examples
Lists in daily life
![]() ![]() ![]() ![]() Lists in computer science
Lists in Rascal
![]() |