Raze

From APL Wiki
Revision as of 03:18, 18 December 2019 by Marshall (talk | contribs) (Created page with ":''The symbol <source lang=apl inline>⊃</source> is more commonly used for First or Mix.'' {{Built-in|Raze|⊃}}, or <source lang=j inline>;</source> in J, is a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The symbol is more commonly used for First or Mix.

Raze (), or ; in J, is a monadic function which combines element arrays of a nested vector along the first axis (in accordance with leading axis theory). Thus, the major cells of the Raze of an array are the major cells of its element arrays: unlike Mix, which removes a level of depth while keeping outer and inner axes separate, Raze merges the outer vector's axis with the first axis of each element. Raze is present in A+ and J.

Examples

Raze can turn a vector of vectors into a single vector. Unlike Mix, it inserts no fill elements.

      ⊃(2 3 4;0 1;5)
2 3 4 0 1 5
Works in: A+

When elements of the argument have rank more than 1, Raze combines them along the leading axis, like Catenate First. In A+, the elements must have the same rank and major cell shape or an error results; in J, lower-rank arrays are promoted to a higher rank and arrays are padded with fills to a common major cell shape.

      ⊃(⍳2 2;-⍳4 2)
 0  1
 2  3
 0 ¯1
¯2 ¯3
¯4 ¯5
¯6 ¯7
Works in: A+

Properties

Raze is similar to the Catenate reduction ↑⍪/. If X is a vector whose elements have equal and positive rank, then ↑⍪/X is the Raze of X. The definition differs if X is a singleton vector with scalar elements, because the Raze of X will be a vector while the reduction implementation results in a scalar (or, in NARS2000, a DOMAIN ERROR). This is because Raze treats scalar elements of its argument as singleton vectors, a convention which may be viewed as scalar rank extension or as a result of the idea that a scalar's only major cell is itself.

Raze is the inverse of Partition and Partitioned Enclose on vectors: partitioning, then razing, a vector gives that vector back. It is also an inverse to partition functions which partition major cells along the first axis, although few partition functions do this.

External links

Documentation