Group (BQN)

From APL Wiki
Jump to navigation Jump to search

Group () is a primitive function in BQN that places values at the specified indices in the result. Because each index can appear multiple times in the array of indices, or not at all, each result element is a list of all the values placed there. Group is ambivalent: in the dyadic case, the left argument is the array of indices and the right argument is the array of values. In the monadic case ("Group Indices"), the right argument gives the result indices and the values used are the indices of that argument. The name "Group" is also used for a related primitive in Uiua, which takes two arguments as well as a function to be applied to each result group.

Together with Classify, Group can be used to implement the functionality of Key or K's Group (=) primitive. Group can be used for Partitioned Enclose and Partition in BQN by manipulating the left argument: for example, summing with +⍀ gives a function similar to Partitioned Enclose.

See also

Documentation


APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
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 axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector