>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Dictionary

Nub | ~. _ |

`~.y` selects the nub of`y` ,`` that is, all of its distinct items. For example:
       y=: 3 3 $ 'ABCABCDEF'
       y;(~.y);(~.3);($~.3)
    +---+---+-+-+
    |ABC|ABC|3|1|
    |ABC|DEF| | |
    |DEF|   | | |
    +---+---+-+-+

More precisely, the nub is found by selecting the leading item, suppressing from the argument all items tolerantly equal to it, selecting the next remaining item, and so on. The fit conjunction applies to nub to specify the tolerance used.
If`f` is a costly function, it may be quicker to evaluate`f y` by first evaluating`f~. y` (which yields all of the distinct results required), and then distributing them to their appropriate positions. The inner product with the self-classification table (produced by`=`)`` can be used to effect this distribution. For example:

       f=: *:
       f y=: 2 7 1 8 2 8 1 8
    4 49 1 64 4 64 1 64

       ,.&.>(~. ; f@~. ; = ; (f@~.(+/ .*)=) ; f)y
    +-+--+---------------+--+--+
    |2| 4|1 0 0 0 1 0 0 0| 4| 4|
    |7|49|0 1 0 0 0 0 0 0|49|49|
    |1| 1|0 0 1 0 0 0 1 0| 1| 1|
    |8|64|0 0 0 1 0 1 0 1|64|64|
    | |  |               | 4| 4|
    | |  |               |64|64|
    | |  |               | 1| 1|
    | |  |               |64|64|
    +-+--+---------------+--+--+

       NUB=: 1 : 'x.@~. +/ . * ='           Adverb
       *: NUB y
    4 49 1 64 4 64 1 64

       nubindex=: ~. i. ]
       (nubindex ; (nubindex { ~.)) y
    +---------------+---------------+
    |0 1 2 3 0 3 2 3|2 7 1 8 2 8 1 8|
    +---------------+---------------+

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Dictionary