q){x where x <> “0;0;0”} each (“0;0;0”;“0;0;1”;“0;0;0”)
“”
,“1”
“”
which might help explain the 'length problem - but you get a result you might not expect…
oops, indeed
strange..
Actually, I read the data from a file and here I posted what I thought would be an equivalent:
q)show f:read0 :stats/f69l7.csv"0;0;1""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0""0;0;0"“0;0;0”..q){x where x <> “0;0;0”} each f{x where x <> “0;0;0”}'lengthq))\q)type f0hq)type (“0;0;0”;“0;0;1”;“0;0;0”)0h`
because the types I checked do match. And there I used “each”.
Later I understood the problem.
The file is big (~24MB) and I did not see all possible values from the head. But there are such rows as well:
"4222687844;190345654;1""4227490595;451919285;2""1725924692;4141106660;1""1040033209;1484765725;1""2695285692;3536595978;1"..
and these strings of course have different length. So using “except” is the right choice here.
depending on what you are trying to do, and your data distribution, this may also be of interest
{(flip abc!x)where any x}("JJJ";";")0::stats/f69l7.csv``
I recognized y~x as a match and f[“abc”;] as partial application.
I did not understand the (y;0#y) part right away but here it goes:
(y or nothing of y) selected by (0 or 1) that is a result of the match.
You use 0#y to retain the type (to keep the function polymorphic).
It works and is something to learn from. Thank you.
I read about Protected Evaluation in Q for Mortals. The book mentions function in the first place @[f;…;…]. Also though I read that list indexing syntax is intentionally similar to the syntax of function application, it is interesting how you use it here. Your example gives a better perspective on @[…]: would-be usual “y where y~:x” looks like being split in two cases: success and failure.