Identity operator

From APL Wiki
(Redirected from Lev)
Jump to navigation Jump to search

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
Works in: NARS2000
      3 -⫤ 1
2
      2 +⫣× 5
7
      2 +⊩× 5
10
Works in: TinyAPL

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
Works in: J

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 ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector