Most primitives are specified by the BQN-based implementation in reference.bqn. This document specifies the basic functionality required by those definitions. Descriptions of other primitives are for informational purposes only.
Functions here are defined for atoms only; the reference implementations extend them to arrays.
BQN uses five arithmetic functions that are standard in mathematics. The precision of these operations should be specified by the number type.
+- and Subtract - invert addition, with -๐ฉ equivalent to 0-๐ฉ and ๐จ-๐ฉ equivalent to ๐จ+-๐ฉร generalizes repeated addition.รท inverts multiplication, with รท๐ฉ equivalent to 1รท๐ฉ and ๐จรท๐ฉ equivalent to ๐จรรท๐ฉโ generalizes repeated multiplication, and Exponential โ is Power with Euler's number e as the base.The three higher functions ร, รท, and โ apply to numbers and no other atomic types. + and - apply to numbers, and possibly also to characters, according to the rules of the affine character type:
+ is the character with code point c and the other is a number n (in either order), then the result is the character with code point c+n.- is the character with code point c and the right is a number n, the result is the character with code point c-n.- are characters, the result is the difference of their respective code points.In the first two cases, if the result would not be a valid Unicode code point, then an error results. The remaining cases of + and - (adding two characters; negating a character or subtracting it from a number) are not allowed.