Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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
  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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://557196]
[perldigious]: Also coincidentally, I'm currently in the middle of a winter storm that has dropped 1 foot of snow and is expected to drop another. I might have to adapt this for customers/vendors who come visit and put it at the beggining of every presentation I give.
[Discipulus]: the photo was removed... Cyrano de Berjerac was not of the same idea..
[stevieb]: perldigious: video near our hq in Montreal. Here in Calgary, it's -28c... we've only got 3" of snow so far, but there are several feet in the mountains already
[perldigious]: Snowshoeing time stevieb? I need to buy a pair so I can walk my German Shepherd properly through the country.
[stevieb]: yeah, I snowshoe a fair amount in the mountains. I also use spikes similar to these very often as well
[perldigious]: Discipulus: alternate link

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2016-12-06 16:30 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (112 votes). Check out past polls.