Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^6: Derangements iterator (callbacks)

by tye (Sage)
on Dec 30, 2005 at 19:11 UTC ( [id://520046]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Derangements iterator (callbacks)
in thread Derangements iterator

But the iterator already existed. I find it easier to use the iterator to make a callback then to reimplement the algorithm recursively... (:

But enough good-natured intentionally talking at cross purposes... I was curious in what order your program produced the derangements and it told me:

b a d c b a d c b a d c b a d c ...

So I'll still keep my iterator-from-the-get-go. ;)

Update: If this "not too difficult" technique is too difficult for its own creator to correctly apply... And the point still stands that using an iterator via a call-back interface is trivial while using a call-back interface via an interator isn't even possible in stock Perl 5.

- tye        

Replies are listed 'Best First'.
Re^7: Derangements iterator (callbacks)
by Roy Johnson (Monsignor) on Jan 01, 2006 at 15:21 UTC
    Notwithstanding the fact that I bungled the code somewhere...what you call "my program" is effectively a translation of jdporter's program. Translated properly, it will return exactly the same results in exactly the same order. I've located my mistake and fixed.

    Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found