Stephen P. Potter wrote:
> Lightning flashed, thunder crashed and Perl6 RFC Librarian
<[EMAIL PROTECTED]>
> whispered:
> | =head1 TITLE
> |
> | Builtin: partition
> |
> | =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.
>
> This is very similar to what unzip does.
Yes. The new version of the partition RFC (posted overnight) makes the
distinction clear.
> Would it be better to combine
> them into a single function that could do both operations (and possibly
> others) with a flag?
Nathan Wiger is currently following up this path. If he can find acceptable
syntax we'll consider it. I'm worried about making this functionality more
confusing than it has to be though, so we'll have to see what it looks like.
> In fact, couldn't all this (zip, unzip, partition) be
> handled as part of pack and unpack?
>
No. They are lazily evaluated and require special optimisations to allow
them to work on like iterators on subsets of sparse, masked, or sliced
arrays. They can all be handled (sort of) by using lazily evaluation list
generation functions (RFC 81), but these three functions are so fundamental
to using 1d arrays as n-dim matrices that requiring complex code to roll
your own would be less than ideal. The narrow scope of these functions also
makes them much easier to optimise.
They are likely to end up in a module, however.