Classify
Revision as of 17:01, 27 January 2024 by Marshall (talk | contribs) (Created page with "'''Self-classify''', or '''index-in-nub''', is a monadic function that gives the index of each of its argument cells in the unique argument cells, which can be implemented as <syntaxhighlight lang=apl inline>{(∪⍵)⍳⍵}</syntaxhighlight> or <syntaxhighlight lang=apl inline>(∪⍳⊢)</syntaxhighlight>. This result is another representation of the boolean matrix returned by the earlier function Nub in defined by Iverson. Classify is implement...")
Self-classify, or index-in-nub, is a monadic function that gives the index of each of its argument cells in the unique argument cells, which can be implemented as {(∪⍵)⍳⍵}
or (∪⍳⊢)
. This result is another representation of the boolean matrix returned by the earlier function Nub in defined by Iverson. Classify is implemented in BQN as ⊐
and Uiua as ⊛
.
A use of Classify in APL is to avoid issues with comparison tolerance when implementing Nub Sieve. In a naive implementation, some cells might match others that are excluded from the result of Unique, leading to inconsistent results. Classify ensures that the cells are partitioned cleanly into groups where each matches its first element.
External links
Documentation