v←10 20 30
v₁²400
A superscript, such as ², applies an operation to a number, array or function. A numeric subscript, such as ₁, selects positions from an array or axes for a function. Both bind more tightly than function application. v₁² is the square of item 1 of v:
On an array, an attached script applies to the preceding token. A modifying script on a function applies to the whole function on its left, as an ordinary monadic operator does: f∘g⁻ is (f∘g)⁻. Enclosure ˢ instead applies to the preceding token: f⍣gˢ uses the scalar holding g; (f∘g)ˢ holds the whole composition. A separated script applies to the whole preceding run.
Typing glyphs gives the keys for typing superscripts and subscripts. For bare inverse ⁻, type Alt-6, -, then Space. Alt-6 then -1 gives ⁻¹, a negative power on numbers or a negative Rank on functions.
On a number or array, a superscript digit is a power:
A power of ¯1, written ⁻¹, is the reciprocal:
ᵀ swaps rows and columns:
In 2 3², the superscript applies only to the 3:
In [2 3]², it applies to the whole list:
After a space, a superscript applies to the whole run on its left:
The run can be any expression, such as ≥x:
In a strand of names, each name is a separate run, so x y ² applies ² only to y:
A spaced superscript also needs a space after it:
On a function, numeric superscripts specify cell ranks: f¹ is f⍤1, f⁰ ¹ is f⍤[0 1], and f⁰ ¹ ² is f⍤[0 1 2]. Adjacent digits form one rank, so f¹² means rank 12. Spaces separate ranks. A negative rank counts back from the argument’s rank, so f⁻¹ works on cells with one fewer axis than the argument. Unlike ⍤, a superscript rank needs no separator before a numeric argument: -⁰5.
Here +/¹ sums each row of m, +⁰ ¹ adds one left scalar to each right row, and ⌽⁻¹ reverses each row:
Bare f⁻ is the inverse of f, the same as f⍣¯1. The minus has no superscript digit immediately after it: f⁻¹ is rank ¯1, while f⁻ ¹ applies the inverse at rank 1. Use f⍣2 to repeat a function twice, because f² means rank 2.
f⁻ Y gives the X for which f X is Y. Inverses follow BQN’s specification of inferred properties. The inverse of the exponential * is the natural logarithm:
Monadic Encode ⊤ gives a number’s binary digits. Its inverse reads the digits back into a number:
In a dyadic call, X f⁻ Y is the Z for which X f Z is Y. The inverses of 2× and 2* are division by 2 and the base-2 logarithm:
Inverting Replicate puts fill where the mask has zeros:
+\⁻ turns running sums back into the numbers they came from:
The same goes for a derived function such as -¨:
A bound function such as 2↣× is inverted as a whole too:
Numeric superscripts just after a number remain powers: +↢3⁻¹ adds a third. Bare +↢3⁻ would instead try to invert the number 3, which raises a DOMAIN error. To invert a function that ends in a number, put the function in parentheses:
A space before the superscript applies it to the whole preceding run, so the parentheses can be left out:
With the axis operator ⍠, the inverse can also go before it: #⁻⍠¯1 is the same function as (#⍠¯1)⁻.
Inverses follow the rules of ⍣. A function built with Atop, After, Before, a bound argument, Each, Rank, Commute or a scan has an inverse when its parts do. f⁻←g attaches g as the inverse of the function named by f.
Bitwise ᵇ is a monadic operator that applies a Boolean function to integer bits. For example, 6∧ᵇ3 is 2ₓ.
Unary ᵘ calls a function with its right argument alone: X fᵘ Y is f Y. For example, 10-ᵘ3 is ¯3.
fˢ is a scalar holding the function f, as ⊂ encloses a subject. ⊂ can’t enclose a function, because written next to one it forms a train. Power uses a function scalar as a stopping predicate. Like any scalar, +ˢ has an empty shape:
Its depth counts the one layer around the function:
DOMAIN: a function with no known inverse, ᵀ on a function, or ˢ on an arraySYNTAX: a superscript after a space that doesn’t stand alone, as in 2 3 ²+1On an array, a subscript selects a major cell. v₁ is 1⌷v:
A negative subscript counts from the end:
A single subscript selects a matrix row. Numeric subscripts separated by spaces form one coordinate: m₁ ₀ is m.[1 0]. Adjacent digits form one position: v₁₂ selects position 12. Parentheses keep sequential selections separate: (a₁)₂ selects item 2 of item 1:
After a dotted path, a subscript selects from the value at the end of that path:
With a space before it, a subscript selects from the whole run on its left:
As with a superscript, the run can be any expression:
A spaced subscript also needs a space after it.
A subscripted item can be an assignment target:
Modified assignment works too:
Use numeric subscripts for literal positions along successive axes. Use Index ⌷ or bracket indexing for computed positions, vectors of positions, keys or whole axes.
After a function, numeric subscripts choose axes, as Axis does. +/₀ is +/⍠0, and +/₀ ₁ is +/⍠[0 1]:
In f⁝x₁, the subscript indexes x before the call. (f⁝x)₁ indexes the call’s result. An array of functions is still an array: fs₁ selects its item 1.
The subscript letters ₓ, ⱼ, ₑ and ᵣ are parts of numbers, as in 3ₓ and 1ᵣ3. Numbers covers them. Between two items, ⱼ, ₑ and ᵣ form one number: xⱼy is x+y×0ⱼ1, xₑy is x×10*y, and xᵣy constructs a rational from integer components. A trailing ᵣ converts to the unbounded integer/rational domain: 3ᵣ means 3ᵣ1, and a result that is a whole number stays in that domain. ÷ on ordinary integers floors. ÷ᵣ gives the exact rational quotient of the same integers, and ÷ₐ gives a float. After a name or any other item except a number or a list of literals, ₓ floors the value to machine integers. xₓ is ⌊ₓx:
After a function, ₓ floors its results to ordinary integers under either kinds setting. Numbers gives the static conversion rules.
÷ₓ floors the exact quotient as Python’s // does and gives an ordinary integer, as ¯32768ₓ₂÷ₓ¯1ₓ₂ gives 32768ₓ. ⌊ₓ, ⌈ₓ and ÷ₓ each compute their integers in one pass:
The sized integer markers ₓ₁, ₓ₂, ₓ₄ and ₓ₈ give fixed-width integers occupying 1, 2, 4 or 8 bytes. All the digits after ₓ form the width, so ₓ₁₆ is invalid. Put parentheses around a conversion before indexing it, as in (vₓ₁)₂. Fixed-width integers gives the conversion and promotion rules.
After a function, a sized marker converts the function’s results:
The float-width markers ₕ, ₛ and ₚ work the same way. After a function it makes the function’s results floats of that width, and after an array it converts the array, as •float does:
ₐ (approximate) converts values to real floats. After an array, ₐ takes a complex number’s real part at the width of its parts, converts an exact number or a Boolean to a float of the default width, and keeps a float’s width:
After a pervasive function other than √, ⊛, *, ○ and ○⁻, ₐ converts the arguments to real floats before the call, taking each complex argument’s real part: !ₐ25ₓ computes in floats rather than in overflowing integers. The floats have the width that the arguments’ float promotion gives, which never depends on their values. After a function that isn’t pervasive, such as ≢, ₐ converts the results. ÷ₐ selects float division before computing, rather than converting a floored integer quotient. After √, ⊛, *, ○ or ○⁻, ₐ gives the real part of the principal value, including when the result is outside the real domain. √ₐ¯4 is 0, the real part of 0j2. ¯8*ₐ÷3 is 1, the real part of the principal root 1+i√3. √ₐ, ⊛ₐ and *ₐ each run as one kernel. Under ∂, their slopes are the slopes of their real parts. Numbers gives the rules:
SYNTAX: a subscript after a space that doesn’t stand alone, as in 2 3 ₁+1, or that is an assignment target, as in v ₁←5SYNTAX: ₋ with no digit after itSYNTAX: ⱼ or ₑ beside a function or a space, as in f←- ◇ fⱼ1INDEX: the item is a unit, which has no axis to select fromDOMAIN: ₓ on a complex numberBPL also accepts Dyalog’s x*2, f⍣2 and f⍣¯1. BQN writes the inverse as 𝔽⁼. Neither language has subscripts.