Enlist: Difference between revisions

Jump to navigation Jump to search
27 bytes added ,  22:04, 10 September 2022
m
Text replacement - "<source" to "<syntaxhighlight"
m (Text replacement - "</source>" to "</syntaxhighlight>")
m (Text replacement - "<source" to "<syntaxhighlight")
Line 1: Line 1:
{{Built-in|Enlist|∊}} is a [[primitive function]] which returns a [[simple]] [[vector]] of all simple [[scalar]] values in a possibly [[nested array]]. Enlist differs from [[Ravel]] in that Enlist flattens over all layers of nesting, while Ravel flattens only the outermost layer. Enlist shares its [[glyph]] <source lang=apl inline>∊</syntaxhighlight> with the dyadic function [[Membership]].
{{Built-in|Enlist|∊}} is a [[primitive function]] which returns a [[simple]] [[vector]] of all simple [[scalar]] values in a possibly [[nested array]]. Enlist differs from [[Ravel]] in that Enlist flattens over all layers of nesting, while Ravel flattens only the outermost layer. Enlist shares its [[glyph]] <syntaxhighlight lang=apl inline>∊</syntaxhighlight> with the dyadic function [[Membership]].


== Examples ==
== Examples ==
Line 5: Line 5:
Enlist is equivalent to a [[wikipedia:depth-first search|depth-first search]] collecting all simple scalars, where each layer (which in turn can be of any rank) is traversed in [[ravel order]].
Enlist is equivalent to a [[wikipedia:depth-first search|depth-first search]] collecting all simple scalars, where each layer (which in turn can be of any rank) is traversed in [[ravel order]].


<source lang=apl>
<syntaxhighlight lang=apl>
       ⎕←MAT←2 2⍴'MISS' 'IS' 'SIP' 'PI'
       ⎕←MAT←2 2⍴'MISS' 'IS' 'SIP' 'PI'
┌────┬──┐
┌────┬──┐
Line 27: Line 27:
Enlist acts like [[Ravel]] for simple arrays. This includes simple scalars, where the result is a [[singleton]] vector.
Enlist acts like [[Ravel]] for simple arrays. This includes simple scalars, where the result is a [[singleton]] vector.


<source lang=apl>
<syntaxhighlight lang=apl>
       ⎕←mat←4 4⍴⍳16
       ⎕←mat←4 4⍴⍳16
  1  2  3  4
  1  2  3  4

Navigation menu