An identity operator is an operator which returns (one of) the operand(s). These are Null (⊙
) in NARS2000; Ident (⫤
), Lev (⫣
) and Dex (⊩
) in TinyAPL; Ident (]:
), Lev ([.
) and Dex (].
) in J.
Null and Ident are monadic operators that return the only operand, Lev and Dex are dyadic operators that respectively return the left and right operand.
Examples
9 -⊙ 5
4
3 -⫤ 1
2
2 +⫣× 5
7
2 +⊩× 5
10
Description
In the simplest definition, the operators just return the functions as described above. Where implementations diverge is in the handling of array operands. NARS2000 disallows this in its Null operator. TinyAPL chooses to return a constant function, as if arr⍨⫤
and similar were written, J makes the three operators behave specially and allows them to return arrays:
2]:+1
3
Purpose
The reason why identity operators exist in NARS2000 and J and TinyAPL are different. In NARS2000, /
and other glyphs are hybrids, which means that they can both mean functions or operators. Null solves this by casting the operand to a function. J and TinyAPL introduced the three identity operators as a result of the introduction of modifier trains, which are a generalization of trains to operator tines. When one wants to not process one of the tines and return the operand directly, an identity operator is needed. In other words, identity functions are to arguments as identity operators are to operands.
External links
Documentation
APL built-ins [edit]
|
Primitives (Timeline) |
Functions
|
Scalar
|
Monadic
|
Conjugate ∙ Negate ∙ Signum ∙ Reciprocal ∙ Magnitude ∙ Exponential ∙ Natural Logarithm ∙ Floor ∙ Ceiling ∙ Factorial ∙ Not ∙ Pi Times ∙ Roll ∙ Type ∙ Imaginary ∙ Square Root ∙ Round
|
Dyadic
|
Add ∙ Subtract ∙ Times ∙ Divide ∙ Residue ∙ Power ∙ Logarithm ∙ Minimum ∙ Maximum ∙ Binomial ∙ Comparison functions ∙ Boolean functions (And, Or, Nand, Nor) ∙ GCD ∙ LCM ∙ Circular ∙ Complex ∙ Root
|
Non-Scalar
|
Structural
|
Shape ∙ Reshape ∙ Tally ∙ Depth ∙ Ravel ∙ Enlist ∙ Table ∙ Catenate ∙ Reverse ∙ Rotate ∙ Transpose ∙ Raze ∙ Mix ∙ Split ∙ Enclose ∙ Nest ∙ Cut (K) ∙ Pair ∙ Link ∙ Partitioned Enclose ∙ Partition
|
Selection
|
First ∙ Pick ∙ Take ∙ Drop ∙ Unique ∙ Identity ∙ Stop ∙ Select ∙ Replicate ∙ Expand ∙ Set functions (Intersection ∙ Union ∙ Without) ∙ Bracket indexing ∙ Index ∙ Cartesian Product ∙ Sort
|
Selector
|
Index generator ∙ Grade ∙ Index Of ∙ Interval Index ∙ Indices ∙ Deal ∙ Prefix and suffix vectors
|
Computational
|
Match ∙ Not Match ∙ Membership ∙ Find ∙ Nub Sieve ∙ Encode ∙ Decode ∙ Matrix Inverse ∙ Matrix Divide ∙ Format ∙ Execute ∙ Materialise ∙ Range
|
Operators |
Monadic
|
Each ∙ Commute ∙ Constant ∙ Replicate ∙ Expand ∙ Reduce ∙ Windowed Reduce ∙ Scan ∙ Outer Product ∙ Key ∙ I-Beam ∙ Spawn ∙ Function axis ∙ Identity (Null, Ident)
|
Dyadic
|
Bind ∙ Compositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner Product ∙ Determinant ∙ Power ∙ At ∙ Under ∙ Rank ∙ Depth ∙ Variant ∙ Stencil ∙ Cut ∙ Direct definition (operator) ∙ Identity (Lev, Dex)
|
Quad names
|
Index origin ∙ Comparison tolerance ∙ Migration level ∙ Atomic vector
|