From APL Wiki
Jump to navigation Jump to search

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].


Link implements {(),}, 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 23 45 6
1 23 45 6
Works in: SHARP APL

Because of the function's asymmetric nature, oddities may appear if the arrays are chained in a wrong order:

      (1 23 4)5 6
│┌───┬───┐│5 6
││1 23 4││   
Works in: SHARP APL

Similarly, the chaining fails if the rightmost array is already nested:

      1 23 4⊃<5 6
1 23 45 6
Works in: SHARP APL

What we really wanted was:

      1 23 4⊃<<5 6
1 23 4│┌───┐│
      ││5 6││
Works in: SHARP APL

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



  1. "Language Extensions of May 1983". SATN-45, 1983-05-02.

APL built-ins [edit]
Primitive functions
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialise
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencil
Quad names
Arrays Index originMigration level
Functions Case convert
Operators SearchReplace