8.3.1 Context-dependent functions.
The + operator.
The + operator is infixed and
’+’ is its prefixed version. The + operator
will add numbers (see Section 7.3.2), concatenate strings (see
Section 5.2.13), and convert a number to a string if
necessary. Addition makes sense for other objects, and + can
flexibly deal with them; the result of using the + operator
depends on the nature of its arguments.
Examples
or:
or:
or:
(See Section 6.1.9.)
or:
or:
or:
or:
[[1,2],[3,4]]+[[1,2],[3,4]] |
or:
(This is a polynomial; see Section 11.1.1.)
or:
or:
The -, * and / operators.
The -, * and
/ operators (and their
prefixed versions ’-’, ’*’ and ’/’), like
the + operator, are flexible and operate on compound objects
(such as lists and sequences), but do not concatenate strings.
Examples of - and ’-’.
or:
or:
or:
[[3,4],[1,2]]-[[1,2],[3,4]] |
or:
Examples of * and ’*’.
or:
or:
or:
or:
or:
or:
These compute the scalar product.
or:
These compute the scalar product.
[[1,2],[3,4]]*[[1,2],[3,4]] |
or:
or:
or:
or:
Examples of / and ’/’.
or:
or:
[[1,2],[3,4]]*1/[[1,2],[3,4]] |
[[1,2],[3,4]]/[[1,2],[3,4]] |
(This is term-by-term division.)