Help for this page

Select Code to Download


  1. or download this
    sub split_to_n {
      my $n = shift;
      my @p = map {(@_)*$_/$n} 0..$n;
      map {[@_[$p[$_-1]..($p[$_]-1)]]} 1..$n;
    }
    
  2. or download this
    use Data::Dumper;
    $Data::Dumper::Indent = 1;
    print Dumper split_to_n(3, 'a'..'z');
    
  3. or download this
    sub split_to_n {
      my $n = shift;
    ...
      @_ = reverse @_;
      map {[reverse @_[$p[$_-1]..($p[$_]-1)]]} reverse 1..$n;
    }