Skip to content

Unique R←∪Y

Y may be any array. The result R has the same rank as Y, unless Y is a scalar, in which case R is a one-element vector. The major cells of R are the unique major cells of Y (the unique elements of a vector, the unique rows of a matrix, and so on), in the order in which they first appear in Y.

⎕CT and ⎕DCT are implicit arguments of unique.

Examples


      ∪ 22 10 22 22 21 10 5 10
22 10 21 5

      ∪ v←'CAT' 'DOG' 'CAT' 'DUCK' 'DOG' 'DUCK'
┌───┬───┬────┐
│CAT│DOG│DUCK│
└───┴───┴────┘
      ⊢mat←↑v                                   
CAT 
DOG 
CAT 
DUCK
DOG 
DUCK
      ∪mat                                       
CAT 
DOG 
DUCK
      a←3 4 5⍴⍳20
      a
 1  2  3  4  5
 6  7  8  9 10
11 12 13 14 15
16 17 18 19 20

 1  2  3  4  5
 6  7  8  9 10
11 12 13 14 15
16 17 18 19 20

 1  2  3  4  5
 6  7  8  9 10
11 12 13 14 15
16 17 18 19 20
      ∪a
 1  2  3  4  5
 6  7  8  9 10
11 12 13 14 15
16 17 18 19 20
∪ unique