At 05:33 PM 8/11/00 +0100, Graham Barr wrote:
>On Fri, Aug 11, 2000 at 03:36:21PM -0000, Perl6 RFC Librarian wrote:
> > This and other RFCs are available on the web at
> > http://dev.perl.org/rfc/
> >
> > =head1 TITLE
> >
> > Builtin: partition
> >
> > =head1 VERSION
> >
> > Maintainer: Jeremy Howard <[EMAIL PROTECTED]>
> > Date: 11 August 2000
> > Version: 1
> > Mailing List: [EMAIL PROTECTED]
> > Number: 91
> >
> > =head1 ABSTRACT
> >
> > It is proposed that a new function, C<partition>, be added to Perl.
> > C<partition($partition_size, \@list)> would return @list broken into
> > references to sub-lists, each one $list_size in size.
> >
> > =head1 DESCRIPTION
> >
> > In order to work with lists of arbitary size, it is often necessary to
> > split a list into equal sized sub-lists. A C<partition> function is
> > proposed that achieves this:
> >
> > @list = (1,2,3,4,5,6);
> > @partitioned_list = partition(2, \@list); # ([1,2],[3,4],[5,6])
>
>How is this different to you other RFC for unzip() ?
>
> > @unzipped_list = unzip(3, \@zipped_list); # ([1,3,5], [2,4,6])
The difference is how they group:
@unzipped_list = unzip(3, (1,2,3,4,5,6)); # ([1,3,5],[2,4,6])
@partitioned_list = partition(3,(1,2,3,4,5,6)); # ([1,2,3],[4,5,6])
Or... Let's say you had a 3x3 array implemented as follows:
@array = ( a1, a2, a3,
b1, b2, b3,
c1, c2, c3 );
unzip(3,@array) would return the columns.
partition(3,@array) would return the rows.