5 - Mappings
Published online by Cambridge University Press: 05 June 2012
Summary
Introduction
In this chapter, we shall investigate the important class of relations known as mappings or functions. These are relations between two sets such that every possible element of the first set appears in one and only one ordered pair. We can regard the relation as a list, with the first column listing the elements in the domain, and the second listing the values of the function. A mapping is usually specified either by giving a rule for which y appears in each pair (x, y), or, for finite sets, by listing the value of the mapping for each value of x.
Example 5.1 The relation R = {(n, n2): n ∈ ℤ} is a mapping, and the ‘rule’ is to form the pair containing n as first component, square n and take the result as second component.
Example 5.2 Consider the Modula-2 declaration
f:ARRAY[l‥n] OF INTEGER.
This produces n integers f[1], f[2], …, f[n]. These can be regarded as the values of a function f(m) which is only defined when 1 ≤ m ≤ n, and this function is represented in the computer by a list f of its values. If n is the number of employees in a firm, m is a payroll number, and f(m) is the salary of employee m, this representation of the salary function would be necessary if there were no obvious formula relating m to f(m).
- Type
- Chapter
- Information
- Discrete MathematicsAn Introduction for Software Engineers, pp. 96 - 137Publisher: Cambridge University PressPrint publication year: 1991