Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Which Permute or other module can give me all possible subsets of 6 numbers out of 40?

by Corion (Patriarch)
on Apr 11, 2018 at 07:10 UTC ( [id://1212659]=note: print w/replies, xml ) Need Help??


in reply to Which Permute or other module can give me all possible subsets of 6 numbers out of 40?

If I understand you correctly, this is the basic example of NestedLoops from Algorithm::Loops:

use Data::Dumper; use Algorithm::Loops 'NestedLoops'; my $depth = 6; my $range = 40; NestedLoops( [[1..$range], ( sub { [$_+1..$range] } ) x ($depth-1)], s +ub { print Dumper \@_})

If you want to create all those pairings in memory, NestedLoops can also give you the list instead of invoking a callback.

  • Comment on Re: Which Permute or other module can give me all possible subsets of 6 numbers out of 40?
  • Select or Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found