Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Combinatorics

by jryan (Vicar)
on Aug 22, 2002 at 03:05 UTC ( [id://191911]=note: print w/replies, xml ) Need Help??


in reply to Combinatorics

Set "$set_group_size" to the size you want the chunks to be.
use Data::Dumper; my $set_group_size = 2; my @list = 1..5; print Dumper ([ sumList($set_group_size,@list) ]); sub sumList { my @sumlist; my $size = shift; while ( @_ ) { my @current = splice @_, 0, $size-1; foreach my $item (@_) { push ( @sumlist, [@current,$item] ); } unshift (@_, @current[1..$#current]); } return @sumlist; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://191911]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-03-28 21:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found