Group (BQN): Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-in|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, the right argument gives the result indices and...")
 
m (Text replacement - "Group" to "Group")
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Built-in|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, 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 <code>⊕</code> in [[Uiua]], which takes two arguments as well as a function to be applied to each result group.
{{Built-in|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 <code>⊕</code> 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]] (<syntaxhighlight lang=k inline>=</syntaxhighlight>) primitive. Group can be used for [[Partitioned Enclose]] and [[Partition]] in BQN by manipulating the left argument: for example, summing with <syntaxhighlight lang=apl inline>+⍀</syntaxhighlight> gives a function similar to Partitioned Enclose.
Together with [[Classify]], Group can be used to implement the functionality of [[Key]] or [[K]]'s [[Group (K)|Group]] (<syntaxhighlight lang=k inline>=</syntaxhighlight>) primitive. Group can be used for [[Partitioned Enclose]] and [[Partition]] in BQN by manipulating the left argument: for example, summing with <syntaxhighlight lang=apl inline>+⍀</syntaxhighlight> gives a function similar to Partitioned Enclose.


== See also ==
== See also ==

Latest revision as of 20:15, 31 January 2024

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