add tag
Joe Killian (imported from SE)
For this first row found idiom `(w∘{(↓⍺)⍳↓⍵})` there seems no reduction in search time even though the first search would be hashing the array making later searches much faster?

          w← 100000000 3⍴'123'
          w←w,[1]'321'

          z← ⎕AI[3] ⋄ w∘{(↓⍺)⍳↓⍵}'321' ⋄ (⎕AI[3])-z
    100000001
    2892
          z← ⎕AI[3] ⋄ w∘{(↓⍺)⍳↓⍵}'321' ⋄ (⎕AI[3])-z
    100000001
    2883
Top Answer
Adám (imported from SE)
From the [documentation](http://help.dyalog.com/16.0/Content/Language/Defined%20Functions%20and%20Operators/Search%20Functions%20and%20Hash.htm "Search Functions and Hash Tables"):
>Notice that retaining the hash table pays off only on a second or subsequent application of the derived function. This usually occurs in one of two ways: either the derived function is named for later (and repeated) use, as in the first example below or it is applied repeatedly as the operand of a primitive or defined operator, as in the second example.

          w←100000000 3⍴'123'
          w←w,[1]'321'
    
          f←w∘{(↓⍺)⍳↓⍵}
          z←⎕AI[3] ⋄ f'321' ⋄ (⎕AI[3])-z
    100000001
    2782
          z←⎕AI[3] ⋄ f'321' ⋄ (⎕AI[3])-z
    100000001
    16

[Try it online!](https://tio.run/##SyzI0U2pTMzJT/8PBOWP2iaYG4CBgvGj3i3qhkbG6lwg0XKdaMNYdWMjQ3UurjQQ/1HHjGqNR22TH/Xu0nzUuxnM2lrLVQWUe9Q31dEz2jhW4VF3i0IaWBOYqQGT0NStIlohAA "APL (Dyalog Unicode) – Try It Online")

          w←100000000 3⍴'123' 
          w←w,[1]'321' 
    
          w∘{(↓⍺)⍳↓⍵}{z←⎕AI[3] ⋄ ⎕←⍺⍺ ⍵ ⋄ ⎕←(⎕AI[3])-z}¨'321' '321'
    100000001
    2375
    100000001
    0

[Try it online!](https://tio.run/##SyzI0U2pTMzJT/8PBOWP2iaYG4CBgvGj3i3qhkbG6gpcIOFynWjDWHVjI0MgHyjQMaNa41Hb5Ee9uzQf9W4Gs7bWVlcBFT7qm@roGW0cq/Cou0UByAEJ9e4CIgWgEiRBDZhCTd2q2kMrIEaDSQA "APL (Dyalog Unicode) – Try It Online")

This room is for discussion about this question.

Once logged in you can direct comments to any contributor here.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.