For example,
f = { < -2, 4>, <-1, 1>, <0, 0>, <1, 1>, <2, 4> }
defines the "square" function with domain { -2, -1, 0, 1, 2 } and co-domain { 0, 1, 2,
4 }.
No two ordered pairs in the function have the same first component, but it is
legal for two ordered pairs to have the same second component.
For example, the
pairs
<-1, 1> and <1, 1>
have the same second component, namely, 1.
If <
a
,
b
> is an element of
f
, we write
f(a) = b
.
This gives us a more familiar
description of the above function: the function
f
is defined by
f(i) = i
2
, for i in -2.
..2.
Another name for a function is a
map
.
This is the term used in Chapters 12, 14 and
15 to describe a collection of elements in which each element has a unique
key
part
and a
value
part.
There is, in effect, a function from the keys to the values, and that
is why the keys must be unique.
A
finite
sequence
t
is a function such that for some positive integer
k
, called
the
length
of the sequence, the domain of
t
is the set
{ 0, 1, 2, .
.., k-1 }
. For example,
the following defines a finite sequence of length 4:
t(0) = "Karen"
t(1) = "Don"
t(2) = "Mark"
t(3) = "Courtney"
Because the domain of each finite sequence starts at 0, the domain is often left
implicit, and we write
176