Under

From APL Wiki
Revision as of 15:52, 25 April 2022 by Marshall (talk | contribs) (SHARP and J history)
Jump to navigation Jump to search

Under (), or Dual (¨), is a primitive dyadic operator which takes two function operands. It pre-processes its argument(s) with the monadic right operand, before applying the left operand on/between the result(s), then undoing the pre-processing.[1]

Model

In dialects that support user-defined operators and invertible functions, it can be defined as (or similar):

       _U_ ← {⍺←{⍵ ⋄ ⍺⍺} ⋄ ⍵⍵⍣¯1⊢(⍵⍵ ⍺)⍺⍺(⍵⍵ ⍵)}

Examples

https://leetcode.com/problems/add-two-numbers/
      2 4 3 +_U_(10⊥⌽) 5 6 4
7 0 8

History

The Dual operator, written ¨, appeared in 1983 both in Rationalized APL and SHARP APL[2] just after. In both cases it was defined to be a close composition, so that the overall function has the rank of the right operand; this allows ¨> to serve the purpose of Each from a nested APL. Iverson changed the name to Under for his 1987 A Dictionary of APL, and J uses this name as well. It includes both a close form &. like SHARP and a non-close form &.:.

External links

References

APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
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 axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)
Quad names Index originComparison toleranceMigration levelAtomic vector