Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Challenge: Another Infinite Lazy List

by tmoertel (Chaplain)
on Mar 19, 2005 at 01:25 UTC ( #440841=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    r = foldr merge [] . map (\n -> map (*n) [1..])
  2. or download this
    merge []     ys = ys
    merge xs     [] = xs
        | x < y     = x : merge xs (y:ys)
        | y < x     = y : merge (x:xs) ys
        | otherwise = x : merge xs ys
  3. or download this
    > take 60 (r [2,3,5])

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://440841]
[james28909]: but you could put it all in one sub and return the same data type that was inputted. i could write a small example maybe
[Lady_Aleena]: Their uses are also vastly different.
[Lady_Aleena]: The first two make hashes and arrays from a file, the third returns data from a pre-existing hash.
[Lady_Aleena]: Well, HoH and AoH respectively.
[Lady_Aleena]: But if you want to play, play. I don't mind. 8)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2017-05-24 05:10 GMT
Find Nodes?
    Voting Booth?