Naming Conventions |
|||||
|
Scalar |
Vector |
Matrix |
Any |
Non- |
Boolean |
BS |
BV |
BM |
BA |
BN |
Integer |
IS |
IV |
IM |
IA |
IN |
Float |
FS |
FV |
FM |
FA |
FN |
Numeric |
NS |
NV |
NM |
NA |
NN |
Character |
CS |
CV |
CM |
CA |
CN |
Enclosed |
ES |
EV |
EM |
EA |
EN |
enclosed |
TS |
TV |
TM |
TA |
TN |
Simple |
SS |
SV |
SM |
SA |
SN |
Any |
AS |
AV |
AM |
AA |
AN |
phrase e.g.: .X...Y. ⍝ X←BS; Y←IV |
|||||
combinations: use ISV for Integer scalar∨vector |
|||||
B3, I4 &c. to specify higher ranks. |
|||||
RemoveDuplicates
This phrase should work in all APLs to remove all but the first of each unique item from a vector of any type.
((V⍳V)=⍳⍴V)/V ⍝ V←AV
Examples
⎕FX⍕2 1⍴'r←RemoveDuplicates av' 'r←((av⍳av)=⍳⍴av)/av'
RemoveDuplicates,' ',⎕CR'RemoveDuplicates'
r←RemovDuplicats(⍳)=⍴/
RemoveDuplicates 0 1 0 1 2 1 0 1 2 3 2 1 0
0 1 2 3
RemoveDuplicates'0 1 0 1 2 1 0 1 2 3 2 1 0'
0 123
RemoveDuplicates'zero' 'one' 'zero' 'one' 'two' 'one' 'zero'
zero one two
RemoveDuplicates(0 1)(1 2)(0 1)(1 2)(2 3)(1 2)(0 1)
0 1 1 2 2 3
Specialities
Dyalog and APLX
Dyalog and APLX have implemented the unique monadic function ∪ as a primitive.
Compatibility
CheckedWith: APL2, APLX, Dyalog, NARS2000
Test Cases
Show test cases
Test my code, both Examples and Test Cases.
See also: RemoveDuplicateRows and DeleteMultipleBlanks .
Mentor: PhilLast
Tags: <Duplicates> <DeleteDuplicates> <UniqueItems> <SelectUnique>
APL Wiki