[EMAIL PROTECTED] wrote:
I envision a select, reject, and partition, where
@a.partition($foo)
Returns the logical equivalent of
[EMAIL PROTECTED]($foo), @a.select($foo)]
But only executes $foo once per item. In fact. I'd expect partition
to be the base op and select and reject to be defined as
partition()[1] and partition()[0] respectively...
Can the optimizer handle something like this without too much trouble?
If so, I like this. It's expandable: if you allow additional matches
to be passed in, it could be made into a switch-like statement:
@a.partition( .sheep, .goat)
would return the logical equivalent of
[EMAIL PROTECTED](any(.sheep, .goat)), @a.select(.sheep), @a.select(.goat)]
If you only give it one criterion, this would be equivalent to your
version. The main debate I'm having is whether the 'default'/'reject'
output should go to element 0 or to the last element; I think that a
case could be made that the more intuitive arrangement would be to
return the true portion first, followed by the false portion (or, in
the multipartition version, the first case first, the second case
second, and so on, with whatever's left over going last).
--
Jonathan "Dataweaver" Lang