| 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| | | | +---+---+-+-+ |
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@~. +/ . * =' NB. 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|
+---------------+---------------+