Group (BQN): Difference between revisions
No edit summary |
|||
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 ("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. | {{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