cjm2671
cjm2671

Reputation: 19466

How do I filter a list in KDB?

Let's say I've got a list l:

l: til 10

I want to show all values <3.

I tried this:

l . (l<3)

and

l[l<3]

But neither work. How should I do it?

Upvotes: 1

Views: 1255

Answers (2)

Matthew Leonard
Matthew Leonard

Reputation: 126

You can do this through the use of the where keyword. The where keyword will return the indices of your list that meet your criteria.

To use your example:

q)l:til 10;
q)l[where l<3]
0 1 2

Upvotes: 2

Cathal O&#39;Neill
Cathal O&#39;Neill

Reputation: 3179

I think where is what you're looking for here.

q)l:til 10
q)l where l<3
0 1 2

Upvotes: 2

Related Questions