Lists

advertisement
1.6 Lists
list = an ordered collection of items
Order is important in a list, as is the number of repetitions.
(1)
(John, 50000, 45000)
is an example of a list. It is has three items,
John
50000
45000
In this case John is an employee of NetCo, 50000 is his gross salary and 45000 is his
salary after taxes has been removed.
(John, 45000, 50000)
is a different list from (1) because the order of the items is different.
(2)
(John, 50000)
and
(John, 50000, 50000)
are two different lists because 50000 appears only once in the first but twice in the second.
A list with two items, such as (2) is sometimes called an ordered pair. A list with three
items such as (1) is sometimes called a triple. A list with n items is sometimes called an
n-tuple. A list of numbers is sometimes called a vector. For example,
(2, -1, 4, 0)
is 4-tuple and a vector. Sometimes it is convenient to denote a list by a single letter, e.g.
x = (John, 50000, 45000)
We then use subscripts to denote the individual items. For example, if x is as above then
x1 = John
x2 = 50000
x3 = 45000
Here are some important situations where one uses lists.
1.7 - 1
1.
If we draw a coordinate system for the
plane then we identify points in the
plane with ordered pairs of numbers.
For example the point p in the plane at
the right is identified with the ordered
pair (3,2).
p  (3,2)
2.
3.
3
p  (3, 2)
2
1
A character string is a list of characters.
For example the character string
"Hi there" is a list of eight characters
if we count the space between i and t.
1
2
3
4
A bit string is a list of bits. For example, if the contents of a byte is 01101001
then this is a list of eight bits.
1.7 - 2
Download