* Jonathan Scott Duff ([EMAIL PROTECTED]) [20 Sep 2000 07:15]:
> On Tue, Sep 19, 2000 at 07:29:56PM -0000, Perl6 RFC Librarian wrote:
> > =head1 TITLE
> >
> > Builtin: reduce
[...]
> > Separation:
> >
> > $sorted = reduce { push @{$_[0][$_[1]%2]}, $_[1]; $_[0] }
> > [[],[]],
> > @numbers;
> I don't understand this one.
$sorted = reduce { push @{ ^0 [ ^1 % 2 ] }, ^1; ^0 }, [[],[]], @numbers;
Hence: given an array of two arrays, put odd numbers (i.e. x % 2 == 1)
in the second array, and even numbers (i.e. x % 2 == 0) in the first one
(the zeroth array). Then return the new (filled out) pair of arrays for
the next number.
I like it.
--
iain truskett, aka Koschei. <http://eh.org/~koschei/>
You know you are addicted to coffee if...
16 Instant coffee takes too long.