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

Re^3: Finding all Combinations

by roboticus (Chancellor)
on Jun 23, 2006 at 14:21 UTC ( #557196=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #------------------------------------------------------------
    # Return an iterator of all possible combinations (of all
    ...
        my ($by, $next) = (0, 1);
    
        return sub {
    
  2. or download this
            # We're done after we've returned a list of all symbols
            return () if @position == @list;
    
  3. or download this
            if ( $next ) {
                # We finished all combos of size $by, now do $by+1
                $by++;
    
  4. or download this
                # If new size is larger than list, we're done!
                return () if $by > @list;
    
  5. or download this
    
                # Start with leftmost $by symbols (except last,
    ...
            return @list[ @position ];
        }
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2015-07-07 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls