3,038
edits
Miraheze>Marshall mNo edit summary |
(→Documentation: BQN) |
||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Built-in|Add|+}}, '''Plus''', '''Addition''', or '''Sum''', is a [[dyadic]] [[scalar function]] that [[wikipedia:Addition|adds]] numbers together. As a | {{Built-in|Add|+}}, '''Plus''', '''Addition''', or '''Sum''', is a [[dyadic]] [[scalar function]] that [[wikipedia:Addition|adds]] numbers together. As a basic arithmetic operation, Add is subject to the language's [[number]] specification. Add shares the glyph <source lang=apl inline>+</source> with the [[monadic]] function [[Conjugate]], and is closely related to [[Subtract]] (<source lang=apl inline>-</source>). | ||
== Examples == | == Examples == | ||
Line 17: | Line 17: | ||
Since adding a number to itself is equivalent to doubling that number, we can express the ''double'' function as <source lang=apl inline>+⍨</source>. | Since adding a number to itself is equivalent to doubling that number, we can express the ''double'' function as <source lang=apl inline>+⍨</source>. | ||
=== Reduction === | |||
[[Reduction]] with Add gives the sum of the whole list. | |||
== Scalar mapping == | == Scalar mapping == | ||
In mathematics, addition of two identical structures almost always follows the same rules as in APL: it maps over the structures element-wise. This is a fundamental property of a (finite-dimensional) [ | In mathematics, addition of two identical structures almost always follows the same rules as in APL: it maps over the structures element-wise. This is a fundamental property of a (finite-dimensional) [[wikipedia:vector space|vector space]], in which addition of two vectors is equivalent to adding the coefficients of basis vectors one by one. This property likely inspired APL's definition of a scalar function. | ||
Addition of [[Complex number|complex]] and [[hypercomplex | Addition of [[Complex number|complex]] and [[hypercomplex number]]s can also be considered an element-wise operation, since each of these types of numbers forms a vector space over the reals. Addition of scalars is always performed within a single domain: mixed-type addition such as adding a real to a complex number treats the real number as complex with imaginary part zero. | ||
Addition in mathematics does not exhibit [[scalar extension]]: there is usually no way to add values of different types. The [[Multiply]] function on vector spaces does extend scalars, in that a scalar element of a field can be multiplied by a vector over that field. | Addition in mathematics does not exhibit [[scalar extension]]: there is usually no way to add values of different types. The [[Multiply]] function on vector spaces does extend scalars, in that a scalar element of a field can be multiplied by a vector over that field. | ||
Line 39: | Line 43: | ||
Addition of floating-point numbers may also be subject to [[overflow]], resulting in a [[DOMAIN ERROR]] or an [[infinite]] result. | Addition of floating-point numbers may also be subject to [[overflow]], resulting in a [[DOMAIN ERROR]] or an [[infinite]] result. | ||
== See also == | |||
* [[Times]] | |||
* [[Or]] | |||
* [[Union]] | |||
== External Links == | == External Links == | ||
Line 44: | Line 53: | ||
=== Documentation === | === Documentation === | ||
* [ | * [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Add.htm Dyalog] | ||
* [http://microapl.com/apl_help/ch_020_020_020.htm APLX] | * [http://microapl.com/apl_help/ch_020_020_020.htm APLX] | ||
* [https://www.jsoftware.com/help/dictionary/d100.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/plus#dyadic J NuVoc] | * [https://www.jsoftware.com/help/dictionary/d100.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/plus#dyadic J NuVoc] | ||
{{APL built-ins}} | * [https://mlochbaum.github.io/BQN/doc/arithmetic.html#basic-arithmetic BQN] | ||
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]] |