Enlist: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com")
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>∊</source> 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]] <source lang=apl inline>∊</syntaxhighlight> with the dyadic function [[Membership]].


== Examples ==
== Examples ==
Line 23: Line 23:
       ∊M
       ∊M
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
</source>
</syntaxhighlight>


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.
Line 42: Line 42:
       ⍴∊3                    ⍝ It's now a vector
       ⍴∊3                    ⍝ It's now a vector
1
1
</source>
</syntaxhighlight>


== External links ==
== External links ==

Revision as of 21:51, 10 September 2022

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.

Examples

Enlist is equivalent to a 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>

     ⎕←MAT←2 2⍴'MISS' 'IS' 'SIP' 'PI'

┌────┬──┐ │MISS│IS│ ├────┼──┤ │SIP │PI│ └────┴──┘

     ∊MAT

MISSISSIPPI

     ⎕←M←1 (2 2⍴2 3 4 5) (6(7 8))

┌─┬───┬───────┐ │1│2 3│┌─┬───┐│ │ │4 5││6│7 8││ │ │ │└─┴───┘│ └─┴───┴───────┘

     ∊M

1 2 3 4 5 6 7 8 </syntaxhighlight>

Enlist acts like Ravel for simple arrays. This includes simple scalars, where the result is a singleton vector.

<source lang=apl>

     ⎕←mat←4 4⍴⍳16
1  2  3  4
5  6  7  8
9 10 11 12

13 14 15 16

     (,mat)≡∊mat

1

     ∊3

3

     3 ≡ ∊3                  ⍝ Not the same

0

     ⍴∊3                     ⍝ It's now a vector

1 </syntaxhighlight>

External links

Lessons

Documentation


APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)
Quad names Index originComparison toleranceMigration levelAtomic vector