Classify
Jump to navigation
Jump to search
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