Pair (⍮
) or Juxtapose is a primitive ambivalent function that constructs a vector of its arguments, present in Extended Dyalog APL, dzaima/APL, and BQN (as ⋈
). The monadic case is referred to as Half Pair in Extended Dyalog APL, and is similar to Enclose except that it gives a result of rank 1 rather than 0. This case is called Enlist in BQN, as well as K, where it is the monadic case of ,
(K has no dyadic Pair primitive). Dyadic Pair is similar to the Link primitive in SHARP APL and J, but Link has an asymmetric definition that adds its left argument to a vector right argument rather than creating a new vector.
Pair can be implemented as the dfn {⍺←,⊂ ⋄ ⍺ ⍵}
, or the catenation of the enclosed arguments, written ,⍥⊂
using Over.[1] Pair aids in constructing nested arrays in tacit programming, where stranding by juxtaposition is not available.
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
History
Pair was defined as ⍮
in Extended Dyalog APL in 2018, and then adopted into dzaima/APL. It was added to BQN with the glyph ⋈
in 2021.
Documentation
References
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
|