Case Study | Index << >> |
Compute x⍳x where x is a vector of strings. Begin with an O(n*2) solution. xix←{(1+≢⍵)-+/∨\⍵∘.≡⍵} x← ⍕¨ ?1e3⍴1e5 (xix x) ≡ x ⍳ x 1 ⎕←t←{x∘←⍕¨?⍵⍴1e5 ⋄ 1 1 cmpx 'xix x'}¨ 1e3×1 2 4 8 16 0.000319824 0.000944824 0.00304688 0.0108516 0.0429062 2 ÷⍨/ t 2.9542 3.22481 3.56154 3.95392 |