I like it except for the name, which feels too active to me (ie, if I were to
purge those elements from the array I'd expect the array to be altered, instead
of returning a new array with only those elements).  But I do like the idea.  I
think the name "except" would be pretty nice, though.  Then again, I'm not too
terribly fond of "grep".  If it were named "only", then things might be really
nice.  (Or we could name them "accept" and "except" and be mean :))

> SUMMARY
> 
> Proposal for the "purge" command as the opposite of "grep" in the same way
> that "unless" is the opposite of "if".
> 
> DETAILS
> 
> I've lately been going a lot of greps in which I want to keep all the
> elements in an array that do *not* match some rule.  For example, suppose
> I have a list of members of a club, and I want to remove (i.e. "purge")
> from the list everybody for whom the "quit" property is true.  With grep
> it's done like this:
> 
>    @members = grep {! $_->{'quit'}} @members;
> 
> Obviously that works well enough, but just like "unless" somehow
> simplifies the logic by removing that leading !, "purge" can simplifiy the
> array filter:
> 
>    @members = purge {$_->{'quit'}} @members;
> 
> FWIW, I came up with "purge" because my first inclination was to spell
> "grep" backwards: "perg".  :-)
> 
> -miko
> 
> 
> Miko O'Sullivan
> Programmer Analyst
> Rescue Mission of Roanoke
> 
> 
-- 
Adam Lopresto ([EMAIL PROTECTED])
http://cec.wustl.edu/~adam/

I love apathy with a passion.

                --Jamin Gray

Reply via email to