Doug, Alejandro, acer, thanks a lot for sharing your thoughts.
I have used select in the past, and searching through my archives I see that I had used it for that same purpose as you describe, but it had sunk into the chasm of my memory. Thanks a lot for pointing it out. A few years back, that is exactly the approach I would have found intuitive. It reads like English grammar, doesn't it:
select(is, L, negative)
Perfectly intuitive. This syntax is certainly to be recommended to people like me who forget syntax from one session to the next.
How efficient is it? I'm not sure what to make of the results posted by acer above. While "memory used" is at the high end (relative to other approaches), "cpu time" and "real time" are at the low end. I have noticed that, in the past, when someone points out that "oh great cpu time is low", someone else points out that "well but memory used is high". I was under the impression that "memory used" was the indicator to look at.
Comment in passing: nops is one of those commands that feels very mysterious the first time you encounter it, then becomes indispensable. I have just discovered that nops(L) is not a costless operation. I hadn't put a thought to that before, but it's a potentially important point. This suggests that if nops(L) is needed repeatedly, it is more efficient to assign it, e.g. n:=nops(L); rather than having seq (and similar constructs) compute it repeatedly. By contrast, the size of a Vector is stored within the construct and accessed cheaply. This is really trivial stuff. I'm hoping that by writing it down I will remember it.
memory used=408 bytes, alloc change=0 bytes, cpu time=109.00ms, real time=110.00ms
memory used=5.16KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns
interesting examples, I can reverse-engineer the first two, but I'm not sure what to make of the third one (about the ode)...
It's great to have all of these methods side by side in one place for future reference. Thanks for posting the worksheet. I keep copies of these and, quite often, search through them for inspiration or salvation.