Sequence
A sequence, list, or stream is a fundamental concept in mathematics and computer science. For convenience, we shall define it as an ordered collection of objects from a set , not necessarily distinct, indexed by natural numbers beginning from one. We may also choose to represent a sequence as a function whose domain is either the subset of natural numbers , or the entire set . The restriction that the objects be indexed by natural numbers is somewhat artificial; the requirement is really that the elements can, informally be speaking, "lined up", one after another, so that by starting somewhere and going to the next element and the next and so on, any element can eventually be reached. Thus, while sequences may be infinite, they may not be uncountably infinite, so there is no sequence that contains all the real numbers, because the real numbers are uncountable. (Mathematically speaking, a sequence can be assigned an ordinal number from the set .) For this reason we may just as well choose to index a sequence by integers starting from zero when it is convenient to do so. The requirement that the elements belong to the same set is somewhat artificial in mathematics, where we can just take so that it contains all elements of our sequence anyway. But it is useful in statically typed programming languages to take to be the set of all objects of a particular type, so that sequences can be uniformly processed using functions that expect or produce a certain type.