kb1964
kb1964

Reputation: 21

KDB/Q: Given a matrix, return only the rows where every element in the row is greater than 5

Given a matrix/list of lists M:(1 9 10;120 50 199;15 20 7) Return only the rows where every element in the row is greater than 5.

Upvotes: 1

Views: 243

Answers (3)

Alex R.
Alex R.

Reputation: 721

You may also find this usefull as well:

q){if[all x<M y;:M y]}[8]'[til count M]

Even though the previous solutions seem to be slightly more efficient, a function is always useful.

Upvotes: 1

terrylynch
terrylynch

Reputation: 13657

Could use

M where 5<min flip M

Or a slight alternative to Seans

M where all flip M>5

Upvotes: 1

Sean O&#39;Hagan
Sean O&#39;Hagan

Reputation: 1697

This would do the trick for you:

q)M where all each M>5

Upvotes: 2

Related Questions