Difference between revisions of "Catenate"

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-ins|Catenate|,|⍪}} is a primitive dyadic function that combines two arrays along a shared axis, so that elements of the left argum...")
m (First/last axis forms category)
Line 21: Line 21:
{{APL built-ins}}[[Category:Primitive functions]]
{{APL built-ins}}[[Category:Primitive functions]][[Category:Functions with first- and last-axis forms]]

Latest revision as of 13:52, 28 May 2020


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


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