1

For instance, if I have a list a:2 5 3 1, I can match another list against it, say b:3 5, which matches the 3 at a[2] and the 5 at a[1]. I am interested in getting my hands on the indices 2 1.

I tried where 3 5 in 2 5 3 1 but didn't work.

chrisaycock
  • 36,470
  • 14
  • 88
  • 125
mchen
  • 9,808
  • 17
  • 72
  • 125

1 Answers1

3

I think you should use ? for this:

q)2 5 3 1?3 5
2 1

http://code.kx.com/q/ref/search/#find

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
WooiKent Lee
  • 1,301
  • 6
  • 4
  • Thanks, however this doesn't appear to work in queries: `select b ? a from flip `a`b!(1 2 ; (3 2 1; 3 2 1))` gives the error: `rank` – mchen May 22 '14 at 18:16
  • 1
    note that `?` only returns the index of the first occurence. Sounds like this is what you want anyways, but worth noting. If you want all locations then something like `where each b=\:a` – JPC May 27 '14 at 20:44