Addition¶
Note
This page concerns the +
operator on numbers; for the +
operator on types, see sum types; for
the +
operator on graphs, see overlay.
Values of all numeric types can be added using the +
operator. For example:
Disco> 1 + 2
3
Disco> (-5) + 2/3
-13/3
If you ask for the type of +
, you get
Disco> :type +
~+~ : ℕ × ℕ → ℕ
which says that it is a function taking a pair of natural numbers and returning a natural number. However, as mentioned above, it also works on other numeric types such as integers and rational numbers.