I’m looking for the equivalent of “where” that can be applied to listsof arbitrary types. For example suppose I havex: string each 100 101 102 202 103 1004 1005How would I filter this to return only strings of length 4 or greater?
To: personal-kdbplus@googlegroups.com
X-Mailer: Apple Mail (2.1251.1)
then you should use the where function
q)x where 4<=count each x
“1004”
“1005”
Regards,
Attila
On 1 Nov 2011, at 20:41, Don Nguyen wrote:
> I’m looking for the equivalent of “where” that can be applied to lists
> of arbitrary types. For example suppose I have
>
> x: string each 100 101 102 202 103 1004 1005
>
> How would I filter this to return only strings of length 4 or greater?
>
> –
> You received this message because you are subscribed to the Google =
Groups “Kdb+ Personal Developers” group.
> To post to this group, send email to =
personal-kdbplus@googlegroups.com.
> To unsubscribe from this group, send email to =
personal-kdbplus+unsubscribe@googlegroups.com.
> For more options, visit this group at =
http://groups.google.com/group/personal-kdbplus?hl=en.
>
To: personal-kdbplus@googlegroups.com
X-Mailer: Apple Mail (2.1084)
> x: string each 100 101 102 202 103 1004 1005
>
> How would I filter this to return only strings of length 4 or greater?
“where” works (in this sense) on any boolean vector
apply your test, apply where, apply back to the list
q)x where 4<=count each x
“1004”
“1005”
as a function, you could write
q)filter:{y where x y}
q)filter[4<=count each]x
“1004”
“1005”