On Wednesday, December 4, 2002, at 09:11  PM, John Williams wrote:

On Wed, 4 Dec 2002, Miko O'Sullivan wrote:
FWIW, I came up with "purge" because my first inclination was to spell
"grep" backwards: "perg".  :-)
While "purge" is cute, it certainly is not obvious what it does.  Of
course neither is "grep" unless you are an aging unix guru...
The idea certainly has merit, though. It _is_ a quite common operation.

What about "divvy" (or are we already using that for something else?)

my(@a,@b) = divvy { ... } @c;

Other possibilities from the ol' thesaurus: C<allot>, C<deal>, C<dole>, C<dispense>.

<thinking aloud...>

Note that this does not generalize for cases > 2. If you want to split things into, say, three different lists, or five, you have to use a 'given', and it gets less pleasant. Perhaps a C<divvy> can be a derivation of C<given> or C<for> by "dividing the streams", either like this:

my(@a,@b,@c,@d) = divvy {
/foo/ ::
/bar/ ::
/zap/ ::
} @source;

or this (?):

divvy( @source; /foo/ :: /bar/ :: /zap/ ) -> @a, @b, @c, @d;


where C<::> is whatever delimiter we deem appropriate, and an empty test is taken as the "otherwise" case.

Just pondering. Seems like a useful variation on the whole C<given> vs. C<grep> vs. C<for> theme, though.

MikeL



Reply via email to