On 11 Aug 2000, Perl6 RFC Librarian wrote: > its arguments. C<unzip($list_size, \@list)> would reverse this operation. [...] > In order to reverse this operation we need an C<unzip> function: > > @zipped_list = zip(\@a,\@b); # (1,2,3,4,5,6) > @unzipped_list = unzip(3, \@zipped_list); # ([1,3,5], [2,4,6]) Would it not be more natural to pass the *number* of lists to unzip, rather than the desired length? This way, unzip() would know to pick off elements two-at-a-time, three-at-a-time, etc., rather than having to go through the zipped list, count the elements, divide by $list_size, etc. Unless I misunderstood the example and you wanted the result to be ([1,2,3], [4,5,6]) in which case unzip would not have to do nearly as much work. But then (1..7) would unzip(3) into ([1,2,3], [4,5,6], [7]). Cheers, Philip -- Philip Newton <[EMAIL PROTECTED]>
- Re: RFC 90 (v1) Builtins: zip() and unz... Dave Storrs
- Re: RFC 90 (v1) Builtins: zip() an... Ariel Scolnicov
- Re: RFC 90 (v1) Builtins: zip() and unzip() Brad Hughes
- Re: RFC 90 (v1) Builtins: zip() and unzip() Mike Pastore
- Re: RFC 90 (v1) Builtins: zip() and unzip() Damian Conway
- Re: RFC 90 (v1) Builtins: zip() and unzip() John Porter
- Re: RFC 90 (v1) Builtins: zip() and unz... Dan Sugalski
- Re: RFC 90 (v1) Builtins: zip() and unzip() Damian Conway
- Re: RFC 90 (v1) Builtins: zip() and unz... Michael Fowler
- Re: RFC 90 (v1) Builtins: zip() and unzip() Tom Hughes
- Re: RFC 90 (v1) Builtins: zip() and unzip() Philip Newton
- Re: RFC 90 (v1) Builtins: zip() and unzip() Jeremy Howard
- Re: RFC 90 (v1) Builtins: zip() and unzip() John Porter
- Re: RFC 90 (v1) Builtins: zip() and unzip() raptor
- Re: RFC 90 (v1) Builtins: zip() and unzip() raptor
- Re: RFC 90 (v1) Builtins: zip() and unzip() Stephen P. Potter
- Re: RFC 90 (v1) Builtins: zip() and unzip() Jeremy Howard
- Re: RFC 90 (v1) Builtins: zip() and unzip() Stephen P. Potter
- RE: RFC 90 (v1) Builtins: zip() and unzip() Myers, Dirk
- Re: RFC 90 (v1) Builtins: zip() and unzip() Jarkko Hietaniemi
- Re: RFC 90 (v1) Builtins: zip() and unzip() Jeremy Howard