From APL Wiki
Revision as of 09:10, 9 July 2020 by Adám Brudzewsky (talk | contribs) (→‎See also)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Partition (, ) is a dyadic function which splits its right argument into differently sized pieces as determined by the non-negative integer left argument. This article uses to distinguish Partition from Partitioned Enclose (which is always ), but the actual glyph used varies by dialect.

On a vector right argument, the arguments must have the same length with each element in the left argument corresponding to an element in the right argument. Partition begins a new division of its right argument whenever a left argument element is greater than its neighbour on the left (with a 0 assumed to the left of the first element):

Try it online!

      1 1 2 2 2 2 2'HiEarth'
Works in: Dyalog APL

Right argument elements can be skipped by having their corresponding left argument element be 0:

      1 1 2 2 2 0 0'HiEarth'
Works in: Dyalog APL

In the case where the left argument is Boolean, Partition splits its right argument on runs of 0s in the left argument, allowing a very short split-on-delimiter function:

Try it online!

      1 1 1 0 1 1 1 0 1 1 1 1'How are you?'
      ' '()'How are you?'
Works in: Dyalog APL

See also

External links



APL built-ins [edit]
Primitive functions
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
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