⌽"trams"smart
Read Searching and indexing first.
⌽ (Circle Stile)⌽ (Reverse)Reverse puts items in the opposite order along the last axis. On a matrix, it reverses each row:
Reverse undoes itself: its inverse is Reverse again.
⌽ (Rotate)A positive count rotates left; a negative count rotates right. Items that leave one end return at the other.
A vector of counts can rotate each row by a different amount:
The inverse of Rotate turns in the opposite direction, using the same count:
⊖ (Circle Bar)⊖ (Reverse First)⊖ acts along the first axis. A vector has only one axis, so ⌽ and ⊖ do the same thing there. On a matrix, ⊖ reverses or rotates the rows.
Reverse First also undoes itself:
⊖ (Rotate First)Its dyadic inverse reverses the rotation, using the same count:
⍉ (Circle Backslash)⍉ (Transpose)Transpose reverses the order of the axes. A matrix’s rows become its columns:
A 2 3 4 array becomes a 4 3 2 array:
Transpose undoes itself too:
The superscript ᵀ writes monadic Transpose after an array. It is for arrays, not functions. It binds before functions, as the digit superscripts do. After a space it applies to the whole run on its left:
Without a space, Index reads row 1 of the transpose. With a space before ᵀ, it first reads row 1, then transposes that vector:
⍉ (Transpose)Each item on the left gives the destination of the corresponding input axis. 1 0 sends the rows to axis 1 and the columns to axis 0:
A diagonal takes matching positions along two axes: row 0 with column 0, row 1 with column 1, and so on. Sending two axes to the same destination selects their diagonal. The shorter axis determines its length:
With three axes, 1 0 2 swaps the first two. Repeated destinations again select diagonals:
When each axis has a different destination, the inverse undoes the routing. Repeated destinations discard items, so a diagonal has no standalone inverse:
A nested item splits one input axis into several axes. Here the last axis of length 8 becomes two axes of lengths 2 and 4, named "group" and "offset". Each pair gives a destination and length. ∞ computes the length needed to keep the number of items unchanged. The key on the group, "packed", names the axis when it is merged back:
["batch":2 "group":2 "row":3 "offset":4]ₓ
The inverse form, ⍉⁻¹, lists input axes in output order. A nested group merges its axes into one. This puts the group and offset axes together again:
The inverse of a split merges the factors back into their original axis. This bound function remembers the numeric routing:
A named output pattern in ⍉⁻¹ does not record the previous axis order, so it has no standalone inverse.
⌺ (Quad Diamond)⌺ (Stencil)A window is a section of an array around one position. Stencil applies its left operand to each window, with that position at the centre. Its right operand gives the window’s size. At the edges, missing items use fill: zero for these numeric arrays. Enclosing each window shows what the operand receives:
Replace enclosure with summation to add the neighbours:
Two sizes make a rectangular window. Here we sum each three-by-three window:
A two-row specification gives the sizes above the movements. This uses three-item windows centred two positions apart:
⊘ (Valences)A function’s valence is the number of arguments it takes. Valences supplies separate functions for calls with one and two arguments. This function negates with one argument and adds with two:
The inverse uses the inverse of whichever function that valence selects. Here it negates with one argument and subtracts the fixed left argument with two:
@ (Under)f@g applies f to the selection that g makes, and writes it back. The other items stay unchanged. A list of positions selects along the first axis. A value in the function position replaces the selection:
Exact input keeps the reciprocals rational. Positions 1 and 3 hold 2 and 4, whose reciprocals are 1ᵣ2 and 1ᵣ4:
A function inside a one-item list selects where its result is true. Here 2| marks the odd numbers:
A selecting function can also supply the right operand. Drop skips the first item; Under changes only the rest:
With an invertible transformation, Under transforms, applies its left operand, then reverses the transformation. To round down to tenths, multiply by ten, floor, then divide by ten:
Dot selections after Same can supply Under’s selector without a dfn. Here the selected positions are multiplied by ten; a field selector changes just that field:
Under’s inverse keeps the selection and inverts its left function. This decrements the selected items:
⍚ (Agenda)Agenda chooses a function from a list. Each function is a case. Its left operand supplies the case’s position, or a function that computes that position. A false Boolean chooses case 0, and a true Boolean chooses case 1:
A vector of choices picks one case for each cell. Here negative numbers become zero, while nonnegative numbers take their square roots:
⍎ (Hydrant)⍎ (Execute expression)Execute reads a string as code and returns its last result. The string can refer to names already defined here.
Intermediate statements still display their results, even when the last result is assigned. This prints 2 and stores 4 in answer:
Execute’s inverse writes a value as BPL source text that Execute can read back. Exact numbers keep their marks:
⍎ (Execute in)A keyed left argument supplies names for the expression:
⍕ (Thorn)⍕ (Format)Format turns values into text. The numeric vector and its character representation display alike:
The vector has three numbers; the text has five characters, including its two spaces:
A single number on the left sets the decimal places, the number of digits after the decimal point:
⍕ (Format By Specification)A two-item vector gives the field width and decimal places. The width is the number of characters for each number, padded with spaces:
Indexing covers more selections, and each entry in the glyph reference links to its full definitions.
Previous: Searching and indexing · Study guide · Next: Numerical tools