Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Permuting with duplicates and no memory (off by 1)

by tye (Cardinal)
on Apr 02, 2007 at 03:11 UTC ( #607748=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Permuting with duplicates and no memory
in thread Permuting with duplicates and no memory

Just FYI, perhaps you missed this bit from the root node:

do { print "@ARGV\n"; } while( nextPermut­e(@ARGV) );

which is also why I called my routine "nextPermute".

Also note that dragonchild's and my iterators can be reused. For yours to be reusable you probably want to change:

return if $i == -1;

to

if( $i == -1 ) { $first= 1; return; }

- tye        


Comment on Re^3: Permuting with duplicates and no memory (off by 1)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-09-18 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (108 votes), past polls