On Tue, Sep 19, 2006 at 05:38:32PM -0400, Mark J. Reed wrote:
: I have no horse in this race. My personal preference would be to
: leave grep as "grep". My second choice is "select", which to me is
: more descriptive than "filter"; it also readily suggests an antonym of
: "reject" to do a "grep -v" (cf. "if !" vs "unless"). But I'd accept
: "filter", too.
But which *ect do we call the one that returns both? One would like to
be able to say:
@stuff.direct(
{ .wanted } ==> my @accepted;
default ==> my @rejected;
);
somehow. Or even:
@stuff.divvy(
{ .sheep } ==> my @good;
{ .goats } ==> my @bad;
default ==> my @ugly;
);
or maybe the rejected is what is returned:
@stuff.divert(
{ .sheep } ==> my @good;
{ .goats } ==> my @bad;
) ==> my @ugly;
I've put that into parens because I'd like to keep the declarations of
@good and @bad visible. But there's some way to do it with gather and
a switch statement.
my (@good, @bad, @ugly) := gather {
for @stuff {
when .sheep { @good.take($_) }
when .goats { @bad.take($_) }
default { @ugly.take($_) }
}
}
I dunno...at least it emphasizes that the lists are lazily generated...
Anyway, it's not clear to me that grep always has an exact opposite.
Larry