Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^4: Challenge: Another Infinite Lazy List

by demerphq (Chancellor)
on Mar 19, 2005 at 09:06 UTC ( #440892=note: print w/replies, xml ) Need Help??

in reply to Re^3: Challenge: Another Infinite Lazy List
in thread Challenge: Another Infinite Lazy List

Hmm. My variation uses the @v array to store the next value that would come from a given stream, and the @f array to store what value a given stream is incremented by when a value is "popped" from it. When it comes time to return the next value in the sequence the lowest value available is "popped" from the streams. If it could have also come from a stream with a smaller factor it is ignored and the process repeats otherwise the popped value is returned.

As far as I can tell this is basically the same thing as yours, except you multiply and I increment, and the way we handle dupes is slighlty different but the principle is the same. Its just interesting to me, I find the way identical algorithms can look so different at first glance to be fascinating.


  • Comment on Re^4: Challenge: Another Infinite Lazy List

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2019-10-23 23:01 GMT
Find Nodes?
    Voting Booth?