Difference between revisions of "Catenate"
(Created page with "{{BuiltinsCatenate,⍪}} 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:  
<references/>  <references/>  
−  {{APL builtins}}[[Category:Primitive functions]]  +  {{APL builtins}}[[Category:Primitive functions]][[Category:Functions with first and lastaxis 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 length1 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 (noninteger) 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 firstaxis 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 nonempty 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 
References
 ↑ Joseph de Kerf. "The Implementation of Set Functions in APL: A Proposal". APL Quote Quad Volume 28, Issue 3. 199803.