Miko O'Sullivan [mailto:[EMAIL PROTECTED]] wrote:
> SUMMARY
>
> Proposal for the "purge" command as the opposite of "grep" in
> the same way that "unless" is the opposite of "if".
I like it.
But reading it reminded me of another common thing I do
with grep: partitioning a list into equivalence classes.
a simple case:
@pass = grep {$_->ok} @candidates;
@fail = grep {! $_->ok} @candidates;
This could perhaps be expessed as:
(@pass, @fail) = unzip { $_->ok } @candidates;
A more general mechanism might be:
%results = partition
{ $_->pass ? "pass" : $_->fail ? "fail" : "unknown" }
@canditates;
print "pass: @{%results{pass}}";
print "fail: @{%results{fail}}";
print "unknown: @{%results{unknown}}";
Dave.