Catenate: Difference between revisions
m (Text replacement  "http://help.dyalog.com" to "https://help.dyalog.com") 
(→Documentation: BQN) 

Line 29:  Line 29:  
* [https://help.dyalog.com/latest/#Language/Primitive%20Functions/Catenate%20Laminate.htm Dyalog]  * [https://help.dyalog.com/latest/#Language/Primitive%20Functions/Catenate%20Laminate.htm Dyalog]  
* [http://microapl.com/apl_help/ch_020_020_490.htm APLX]  * [http://microapl.com/apl_help/ch_020_020_490.htm APLX]  
* [https://mlochbaum.github.io/BQN/doc/join.html#jointo BQN]  
== References ==  == References ==  
<references/>  <references/>  
{{APL builtins}}[[Category:Primitive functions]][[Category:Functions with first and lastaxis forms]]  {{APL builtins}}[[Category:Primitive functions]][[Category:Functions with first and lastaxis forms]] 
Revision as of 02:28, 28 May 2022
, ⍪

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 
See also
External links
Tutorial
Documentation
References
 ↑ Joseph de Kerf. "The Implementation of Set Functions in APL: A Proposal". APL Quote Quad Volume 28, Issue 3. 199803.