#!/usr/bin/env perl6
use v6;

sub split-list(@list, $length)
{
    my $i = 0;

    gather while $i <= $length
    {
        take [ gather while $i <= $length {
            $i++ and take @list.shift;
        } ];

        take [ @list ];
    }
}

say split-list('a' xx 20, 8).perl;

=begin pod

=head1 NAME

P17 - Split a list into two parts; the length of the first part is given.

=end pod

# vim: expandtab shiftwidth=4 ft=perl6

#!/usr/bin/env perl6
use v6;

sub split-list(@list, $length)
{
    my $i = 0;

    gather while $i <= $length {
        take [ gather while $i <= $length {
            $i++ and take @list.shift;
        } ];

        take [ @list ];
    }
}

say split-list(('a' xx 20).list, 8).perl;

=begin pod

=head1 NAME

P17 - Split a list into two parts; the length of the first part is given.

=end pod

# vim: expandtab shiftwidth=4 ft=perl6

Convert Parcel to List in input args
Convert Parcel to List in input args

'a' xx 20 creates a Parcel, which is immutable and thus can't be shift-ed.
Converting the Parcel to a List allows the example to run correctly again.
