I have a matrix d
where the first three columns are coordinates followed by some other data. I want to make a coordinate cut, so in essence, filter by rows by some function f
.
I hoped I could do filter(f, eachrow(d))
, but it seems filter
doesn't like generators. My current solution is to use mapslices
to create a mask and use the mask on data. But, if possible, I would like to filter without making a mask.
Would a filtered comprehension work for you?
[r for r in eachrow(d) if f(r)]
Which, IIRC, lowers to something involving Iterators.filter
which works on generators.
Last updated: Nov 06 2024 at 04:40 UTC