Raze: Difference between revisions

Jump to navigation Jump to search
140 bytes added ,  22:19, 29 September 2020
Add BQN information
m (Navbox and category)
(Add BQN information)
Line 1: Line 1:
:''The symbol <source lang=apl inline>⊃</source> is more commonly used for [[First]] or [[Mix]].''
:''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 [[monadic function]] which combines [[element]] arrays of a [[nested]] [[vector]] along the first [[axis]] (in accordance with [[leading axis theory]]). Thus, the [[major cell]]s 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]].
{{Built-in|Raze|⊃}}, <source lang=j inline>;</source> in [[J]], or '''Join''' (<source inline>∾</source>) in [[BQN]], 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 cell]]s 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+]], [[J]], and [[BQN]].


== Examples ==
== Examples ==
Line 31: Line 31:
== High-rank extension ==
== High-rank extension ==


Raze can be extended to an argument array of rank greater than 1, allowing it to merge [[wikipedia:Block matrix|block matrices]] or higher-dimensional structures. This extension has not been implemented in any APL, and would not be backwards-compatible in J, since J's Raze implicitly ravels its argument.
Raze can be extended to an argument array of rank greater than 1, allowing it to merge [[wikipedia:Block matrix|block matrices]] or higher-dimensional structures. This extension is part of [[BQN]], but has not been implemented in any APL, and would not be backwards-compatible in J, since J's Raze implicitly ravels its argument.


The axes of a high-rank argument should be paired with those of its element arrays, starting at the first axis (much like [[prefix agreement]]). The elements can be merged without adding fills when the length of an element along a particular axis depends only on its position along that axis in the outer array. That is, in <source lang=apl inline>⊃X</source>, <source lang=apl inline>⍴¨X</source> must match <source lang=apl inline>⊃∘.,/S</source>, where S is a vector containing <source lang=apl inline>≢⍴X</source> vectors followed by any number of scalars. In this case, the shape of <source lang=apl inline>⊃X</source> is <source lang=apl inline>+/¨S</source>. The result can be computed by performing a modified 1-dimensional Raze several times. The modified Raze should maintain some number of leading inner element axes. With the [[Rank operator]] (<source lang=apl inline>⍤</source>) we might write <source lang=apl inline>⍪⍤(1-≢⍴X)/X</source> for a single step in the process, thus reducing along the last axis and catenating along the same axis.
The axes of a high-rank argument should be paired with those of its element arrays, starting at the first axis (much like [[prefix agreement]]). The elements can be merged without adding fills when the length of an element along a particular axis depends only on its position along that axis in the outer array. That is, in <source lang=apl inline>⊃X</source>, <source lang=apl inline>⍴¨X</source> must match <source lang=apl inline>⊃∘.,/S</source>, where S is a vector containing <source lang=apl inline>≢⍴X</source> vectors followed by any number of scalars. In this case, the shape of <source lang=apl inline>⊃X</source> is <source lang=apl inline>+/¨S</source>. The result can be computed by performing a modified 1-dimensional Raze several times. The modified Raze should maintain some number of leading inner element axes. With the [[Rank operator]] (<source lang=apl inline>⍤</source>) we might write <source lang=apl inline>⍪⍤(1-≢⍴X)/X</source> for a single step in the process, thus reducing along the last axis and catenating along the same axis.
Line 42: Line 42:


* J [https://www.jsoftware.com/help/dictionary/d330.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/semi NuVoc]
* J [https://www.jsoftware.com/help/dictionary/d330.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/semi NuVoc]
 
* [https://mlochbaum.github.io/BQN/doc/join.html BQN]
{{APL built-ins}}[[Category:Primitive functions]]
{{APL built-ins}}[[Category:Primitive functions]]

Navigation menu