Split: Difference between revisions

Jump to navigation Jump to search
90 bytes added ,  14:33, 14 July 2020
m
Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com"
m (Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com")
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Built-in|Split|↓}} is a [[monadic]] [[primitive function]] which reduces the [[rank]] of its [[argument]] by converting one of its [[axis|axes]] to one level of [[nested array model|nesting]]. The axis to move defaults to the last axis, but a different axis can be chosen using [[function axis]]. It shares its [[glyph]] <source lang=apl inline>↓</source> with the dyadic function [[Drop]]. Split is a right inverse to [[Mix]].
{{Built-in|Split|↓}} is a [[monadic]] [[primitive function]] which reduces the [[rank]] of its [[argument]] by converting one of its [[axis|axes]] to one level of [[nested array model|nesting]]. The axis to move defaults to the last axis, but a different axis can be chosen using [[function axis]]. It shares its [[glyph]] <source lang=apl inline>↓</source> with the dyadic function [[Drop]]. Split is the [[inverse]] of [[Mix]] in the sense that the latter undoes the enclosing that Split introduced.


== Examples ==
== Examples ==
Line 47: Line 47:


== Alternatives ==
== Alternatives ==
Most dialects do not have Split. Instead, the can use [[Enclose]] (<source lang=apl inline>⊂</source>) with [[bracket axis]] or the [[Rank operator]]:
Most dialects do not have Split. Instead, they can use [[Enclose]] (<source lang=apl inline>⊂</source>) with [[bracket axis]] or the [[Rank operator]]:
<source lang=apl>
<source lang=apl>
       ↓Y
       ↓Y
Line 68: Line 68:
└────┴────┴────┘
└────┴────┴────┘
</source>
</source>
It is common to split a higher-[[rank]] array into its constituent [[major cell]]s. The behaviour of Split on matrices might mislead to the belief that this is what the primitive does. However, it isn't so vectors or arrays of higher rank than 2. Instead, the solution is to use or <source lang=apl inline>⊂[1↓⍳≢⍴Y]Y</source> or <source lang=apl inline>⊂⍤¯1⊢Y</source>:
It is common to split a higher-[[rank]] array into its constituent [[major cell|major cells]]. The behaviour of Split on matrices might mislead to the belief that this is what the primitive does. However, it isn't so for vectors or arrays of higher rank than 2. Instead, the solution is to use or <source lang=apl inline>⊂[1↓⍳≢⍴Y]Y</source> or <source lang=apl inline>⊂⍤¯1⊢Y</source>:
<source lang=apl>
<source lang=apl>
       ⊂[1↓⍳≢⍴Y]Y
       ⊂[1↓⍳≢⍴Y]Y
Line 83: Line 83:
└────┴────┘
└────┴────┘
</source>
</source>
== External links ==
== External links ==


Line 91: Line 92:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/#Language/Primitive%20Functions/Split.htm Dyalog]
* [https://help.dyalog.com/latest/#Language/Primitive%20Functions/Split.htm Dyalog]


{{APL built-ins}}[[Category:Primitive functions]]
{{APL built-ins}}[[Category:Primitive functions]]

Navigation menu