Enlist

From APL Wiki
Jump to navigation Jump to search

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 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.

      MAT2 2'MISS' 'IS' 'SIP' 'PI'
┌────┬──┐
MISSIS
├────┼──┤
SIP PI
└────┴──┘
      MAT
MISSISSIPPI

      M1 (2 22 3 4 5) (6(7 8))
┌─┬───┬───────┐
12 3│┌─┬───┐│
 4 5││67 8││
    │└─┴───┘│
└─┴───┴───────┘
      M
1 2 3 4 5 6 7 8

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

      mat4 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

External links

Lessons

Documentation


APL built-ins [edit]
Primitive functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Case convertUnicode convert
Operators SearchReplace