Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by tye (Sage)
on Apr 02, 2007 at 03:11 UTC ( [id://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        

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (1)
As of 2024-04-24 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found