Vocabulary/tildedot

From J Wiki
Jump to: navigation, search

>> <<   Back to: Vocabulary Thru to: Dictionary

~. y Nub

Rank Infinity -- operates on x and y as a whole, by items of y -- WHY IS THIS IMPORTANT?



Removes duplicates from a list.

More generally, removes any item of an array that matches a preceding item.

   ~. 'abracadabra'
abrcd

Common Uses

1. Remove duplicate values from a list

   ~. 1 3 5 3 5 9 5 2 3 5 7 3 5 7 3
1 3 5 9 2 7

2. Remove duplicate rows from a table

   ]t =. _3 ]\ 1 0 1 1 1 0 1 0 1 0 1 0 1 1 0
1 0 1
1 1 0
1 0 1
0 1 0
1 1 0
   ~. t
1 0 1
1 1 0
0 1 0

Related Primitives

Nub Sieve (~: y)


More Information

1. ~. y is a member of the i. family. 1. ~. y uses tolerant comparison. Use ~.!.0 y for intolerant comparison.

Because of tolerant comparison, the number of items in ~. y may depend on the order of the items of y.

1. The items of ~. y preserve the order of their first occurrence in y. 1. The order of items in ~. y is guaranteed to be the same as the order of partitions in y u/.. 1. ~. y is equivalent to (~: y) # y. 1. If y is an atom, ~. y is a 1-atom list. Otherwise the result of ~. y has the same rank as y.