Addition¶
[This page concerns the +
operator on numbers; for the +
operator on types, see sum types; for
the +
operator on graphs, see overlay.]
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 two natural numbers and returning a natural number. However, as mentioned above, it also works on other numeric types such as integers and rational numbers.
The +
operator can also be used on graphs, where it has the
meaning of overlaying two graphs.