- Identity, Same, or Pass (
⊢) is monadic and returns its only argument.
- Left Identity, or Left (
⊣) is dyadic and returns its left argument.
- Right Identity, or Right (
⊢) is dyadic and returns its right argument.
The right tack glyph
⊢, when used for Right, is almost paired with Identity for the monadic case. Left tack,
⊣ is usually used for Identity as well, but may be given a different meaning, such as Stop in SHARP APL.
Identity functions (Identity in particular) may be used like elements of syntax to break up stranding, or to force a shy result to be shown. They can also be combined with an array-oriented operator to perform structural manipulations on arrays. Identity functions are a central feature of tacit programming, in which functions and operators rather than names are used to direct the flow of arguments. The pairing of both Left and Right with monadic Identity makes it easier to design ambivalent functions which usefully work with one or two arguments.
⊢ 'argument' argument ⊢pi←3.14 3.14
The result of an identity function is never shy, even if the argument is. Thus the result of the second expression above is displayed, although the assignment
pi←3.14 on its own would not produce any display.
Left and Right return the left and right arguments, respectively, when called dyadically.
'left' ⊣ 'right' left 'left' ⊢ 'right' right
As the left operand to Compose, Right makes the resulting derived function ignore its left argument (so the result is produced by a monadic invocation of the right operand, on the right argument). The same pattern can be produced by using Right as the right operand to Atop.
2 ⊢∘- 7 ¯7 2 -⍤⊢ 7 ¯7
In both cases the derived function, when called monadically, simply acts on the right argument, as there is no left argument to ignore.
⊢∘- 7 ¯7 -⍤⊢ 7 ¯7
The mirror image—using only the left argument while ignoring the left—is attained by using Atop (either the operator, or a 2-train) with Left as the right operand.
2 -⍤⊣ 7 ¯2 -⍤⊣ 2 ¯2
Within a function train (as an "argument" function, that is, the rightmost function, or one an even number of steps away), Right indicates the right argument to the train, and Left indicates the left argument. The 3-train
≠⊆⊢ thus applies Partition to the result of Not Equal to on both arguments and the right argument.
' ' (≠⊆⊢) 'split on spaces' ┌─────┬──┬──────┐ │split│on│spaces│ └─────┴──┴──────┘
With Reduce, Left selects the first elements along the reduction axis, and Right selects the last. For example,
⊣⌿ gives the first major cell of an array while
⊣/ gives the first element along each row, for example the first column of a matrix.
⊢A ← 3 4⍴⍳12 1 2 3 4 5 6 7 8 9 10 11 12 ⊣⌿ A ⍝ First row 1 2 3 4 ⊣/ A ⍝ First column 1 5 9 ⊢/ A ⍝ Last row 4 8 12 ⊢⌿ A ⍝ Last column 9 10 11 12
A Scan using Left extends the first element along each axis to the whole axis, while retaining the argument's shape. This is because a scan reduces on prefixes, and the first element of a prefix is the first element of the entire array. On the other hand, Right Scan doesn't change the argument, since the last element from each prefix gives the entire array.
⊣\ 'vector' vvvvvv ⊢\ 'vector' vector
A ⊢¨ 0 ⍝ Extends the right argument 0 0 0 0 0 0 0 0 0 0 0 0 A ⊣¨ 0 ⍝ No need to extend the left argument 1 2 3 4 5 6 7 8 9 10 11 12 A ⊢¨ 1 2 3 ⍝ Non-conforming arguments RANK ERROR A⊢¨1 2 3 ∧
The outer product with Left adds the axes from the right argument to the left argument, while the outer product with Right adds the axes from the left argument to the right argument. In each case the resulting array is constant along any of the added axes. In the case of Right outer product, the result is composed of cells matching the right argument, and can also be obtained by reshaping the right argument.
'left' ∘.⊣ ⍳6 llllll eeeeee ffffff tttttt 'left' ∘.⊢ ⍳6 ⍝ Identical to 4 6⍴⍳6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6