2.3 Sequences

 < Free Open Study > 



2.3 Sequences

2.3.1 Definition

A sequence is written by listing its elements, separated by commas. We use comma as both the "cons" operation for adding an element to either end of a sequence and as the "append" operation on sequences. For example, if a is the sequence 3, 2, 1 and b is the sequence 5, 6, then 0, a denotes the sequence 0, 3, 2, 1, while a, 0 denotes 3, 2, 1, 0 and b, a denotes 5, 6, 3, 2, 1. (The use of comma for both "cons" and "append" operations leads to no confusion, as long as we do not need to talk about sequences of sequences.) The sequence of numbers from 1 to n is abbreviated 1..n (with just two dots). We write |a| for the length of the sequence a. The empty sequence is written either as * or as a blank. One sequence is said to be a permutation of another if it contains exactly the same elements, possibly in a different order.



 < Free Open Study > 



Types and Programming Languages
Types and Programming Languages
ISBN: 0262162091
EAN: 2147483647
Year: 2002
Pages: 262

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net