Exercise 13 | Index << >> |
(∪x)⍳x , index in nub, is an interesting computation (for example, see Dyalog Language Forum message Operator Each-Nub, 2014-05-29). Suppose x is a vector of 4-byte integers, let’s say x←?1e6⍴2e9 . Compute the index in nub faster than (∪x)⍳x . x←?1e6⍴2e9 cmpx '(∪x)⍳x' '(∪t)⍳t←x⍳x' (∪x)⍳x → 2.20e¯1 | 0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ (∪t)⍳t←x⍳x → 1.83e¯1 | -17% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ |