Pair: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "<source" to "<syntaxhighlight")
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Built-in|Pair|⍮}} is a [[primitive function]] equivalent to the [[dfn]] <source lang=apl inline>{⍺←,⊂ ⋄ ⍺ ⍵}</source> which aids in constructing nested arrays during [[tacit programming]] where [[stranding]] by juxtaposition is not available. It is also equivalent to <source lang=apl inline>,⍥⊂</source> using the [[Over operator]] or <source lang=apl inline>,⍨∘⊂⍨∘⊂</source> using only traditional operators. It was introduced in [[Extended Dyalog APL]], and then adopted into [[dzaima/APL]].
{{Built-in|Pair|⍮}} or '''Juxtapose''' is a [[primitive function]] equivalent to the [[dfn]] <syntaxhighlight lang=apl inline>{⍺←,⊂ ⋄ ⍺ ⍵}</syntaxhighlight> which aids in constructing nested arrays during [[tacit programming]] where [[stranding]] by juxtaposition is not available. It is also equivalent to the [[catenate|catenation]] of the [[enclose]]d arguments; <syntaxhighlight lang=apl inline>,⍥⊂</syntaxhighlight> using the [[Over]] [[operator]]<ref>[https://www.jsoftware.com/papers/satn41.htm "Composition and Enclosure"] §
Composition Operators. SATN-41, 1981-06-20.</ref> or <syntaxhighlight lang=apl inline>,⍨∘⊂⍨∘⊂</syntaxhighlight> using only the traditional operators [[Commute]] and [[Compose]]. It was introduced in [[Extended Dyalog APL]], and then adopted into [[dzaima/APL]].


== Common usage ==
== Common usage ==
Line 5: Line 6:


[https://tio.run/##SyzI0U2pSszMTfz//1Hf1EdtE8wUzBUsNLQf9a7T1TT@/x8A Try it online!]
[https://tio.run/##SyzI0U2pSszMTfz//1Hf1EdtE8wUzBUsNLQf9a7T1TT@/x8A Try it online!]
<source lang=apl>
<syntaxhighlight lang=apl>
       6 7 8(+⍮-)3
       6 7 8(+⍮-)3
┌───────┬─────┐
┌───────┬─────┐
│9 10 11│3 4 5│
│9 10 11│3 4 5│
└───────┴─────┘
└───────┴─────┘
</source>
</syntaxhighlight>
{{Works in|[[dzaima/APL]], [[Extended Dyalog APL]]}}
{{Works in|[[dzaima/APL]], [[Extended Dyalog APL]]}}


Line 16: Line 17:


[https://tio.run/##SyzI0U2pSszMTfz//1Hf1EdtE8wUzBUsNLQftU181LvkUe86XU3j//8B Try it online!]
[https://tio.run/##SyzI0U2pSszMTfz//1Hf1EdtE8wUzBUsNLQftU181LvkUe86XU3j//8B Try it online!]
<source lang=apl>
<syntaxhighlight lang=apl>
       6 7 8(+↑⍤⍮-)3
       6 7 8(+↑⍤⍮-)3
9 10 11
9 10 11
3  4  5
3  4  5
</source>
</syntaxhighlight>
{{Works in|[[dzaima/APL]], [[Extended Dyalog APL]]}}
{{Works in|[[dzaima/APL]], [[Extended Dyalog APL]]}}


{{APL built-ins}}
== See also ==
* [[Link]]
 
== References ==
<references />
{{APL built-ins}}[[Category:Primitive functions]]

Revision as of 22:24, 10 September 2022

Pair () or Juxtapose 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 the catenation of the enclosed arguments; ,⍥⊂ using the Over operator[1] or ,⍨∘⊂⍨∘⊂ using only the traditional operators Commute and Compose. 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

See also

References

  1. "Composition and Enclosure" § Composition Operators. SATN-41, 1981-06-20.
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