Wilfred Cho
Wilfred Cho

Reputation: 39

q kdb+ finding index of match elements using a list

Say I have a list

b:1 1 2 3 4

and I want to find the location of the element in list b using another list

a:1 2

When I type in b in\ a, I got

11000b
00000b

where it should be

11000b
00100b

What is going on and how to get the desired answer?

Thanks in advance!

Upvotes: 3

Views: 865

Answers (2)

user8992008
user8992008

Reputation:

You can also use each-both ':

q)in[b]'[a]
11000b
00100b

Upvotes: 0

Thomas Smyth
Thomas Smyth

Reputation: 5644

You need to use each-right /:

q)b in/:a
11000b
00100b

With b in\a the first output is getting passed back in as b. Effectively:

q)1 1 2 3 4 in 1
11000b
q)11000b in 2
00000b

Upvotes: 2

Related Questions