Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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 making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-07-03 18:29 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 (55 votes), past polls