Pair

From APL Wiki
Revision as of 09:57, 12 February 2020 by Adám Brudzewsky (talk | contribs) (Created page with "{{Built-in|Pair|⍮}} is a primitive function equivalent to the dfn <source lang=apl inline>{⍺←,⊂ ⋄ ⍺ ⍵}</source> which aids in constructing nested arrays...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Pair () is a primitive function equivalent to the dfn {⍺←,⊂ ⋄ ⍺ ⍵} which aids in constructing nested arrays during tacit programming where stranding by juxtaposition is not available. It is also equivalent to ,⍥⊂ using the Over operator or ,⍨∘⊂⍨∘⊂ using only traditional operators. It was introduced in Extended Dyalog APL, and then adopted into dzaima/APL.

Common usage

Its plain usage is in pairing up two parallel values:

Try it online!

      6 7 8(+⍮-)3
┌───────┬─────┐
│9 10 11│3 4 5│
└───────┴─────┘

It can also be combined with Mix to increase rank rather than depth:

Try it online!

      6 7 8(+↑⍤⍮-)3
9 10 11
3  4  5


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