Link (⊃
), or ;
in J, is a dyadic primitive function which builds a nested vector out of the two arguments. Link is useful for building a nested array when stranding by juxtaposition is not available. Link first appeared as an extension to SHARP APL[1].
Examples
Link implements {(⊂⍺),⊆⍵}
or ,⍨∘⊂⍨∘⊆
, that is, the concatenation of enclose of the left argument and nest (enclose if simple) of the right argument. This allows to chain the function over multiple arrays to form a nested array. Note that both SHARP APL and J use flat array model, so they allow boxing of a simple scalar.
1 2⊃3 4⊃5 6
┌───┬───┬───┐
│1 2│3 4│5 6│
└───┴───┴───┘
1⊃2⊃3
┌─┬─┬─┐
│1│2│3│
└─┴─┴─┘
Because of the function's asymmetric nature, oddities may appear if the arrays are chained in a wrong order:
(1 2⊃3 4)⊃5 6
┌─────────┬───┐
│┌───┬───┐│5 6│
││1 2│3 4││ │
│└───┴───┘│ │
└─────────┴───┘
Similarly, the chaining fails if the rightmost array is already nested:
1 2⊃3 4⊃<5 6
┌───┬───┬───┐
│1 2│3 4│5 6│
└───┴───┴───┘
What we really wanted was:
1 2⊃3 4⊃<<5 6
┌───┬───┬─────┐
│1 2│3 4│┌───┐│
│ │ ││5 6││
│ │ │└───┘│
└───┴───┴─────┘
Link is different from Pair ⍮
, as Pair simply encloses both arguments and always produces a length-2 vector, so it cannot be used to construct a long nested array of uniform depth like Link does.
External links
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
|