Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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

by tye (Sage)
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;


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

- tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://607748]
[stevieb]: I'd take full responsibility myself... "man, I was so hung over I could barely read what the email said!"
[zarath]: "Smee, the boo-box..."
choroba ponders selling some ticks to a vegan restaurant nearby

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2017-05-24 13:53 GMT
Find Nodes?
    Voting Booth?