From APL Wiki
(Redirected from Concatenate)
Jump to navigation Jump to search

Catenate (,, ) is a primitive dyadic function that combines two arrays along a shared axis, so that elements of the left argument are followed by those of the right along that axis. This axis can already exist or can be created by inserting a length-1 axis (for example, to append a column to a matrix), but to catenate arrays, at least one argument must have the axis already. The operation that combines two arrays of matching shape along a completely new axis, which will then have length 2, is called Laminate. In all APLs, catenating two scalars is allowed and actually performs a lamination. In APLs which allow a function axis for Catenate, Laminate can be invoked by giving a fractional (non-integer) axis.

In most APLs, Catenate (,) defaults to using the last axis if none is specified. Catenate First (), introduced by NARS, defaults to the first axis instead. Array languages based on leading axis theory, such as A+ and J, simplify Catenate by using only the first-axis form (with the glyph ,) and removing the ability to specify an axis, and add a new dedicated Laminate function.

Prototype choice

See also: Empty array prototype

When both arguments to Catenate are empty, the result must also be empty. In this case its shape can be computed without any irregularity, but its prototype is not determined by the definition of Catenate with a non-empty result—in that case, the prototype is obtained from the first result element, but for an empty result there is no such element. As a result, it must be specified: various APLs choose either the left or right argument's prototype,[1] and J chooses the result type based on a hierarchy of types: boxes are chosen in preference to numbers, which are preferred to characters.

Languages Prototype choice
Dyalog APL, VAX APL (DEC) left
APL2, APL*PLUS, APL.68000, A+ right
J type hierarchy

See also

External links




  1. Joseph de Kerf. "The Implementation of Set Functions in APL: A Proposal". APL Quote Quad Volume 28, Issue 3. 1998-03.

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 DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Case convertUnicode convert
Operators SearchReplace