KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Consider the following code that is supposed to print out random numbers: import System.Random.Mersenne main = do g <- (newMTGen Nothing) xs <- (randoms g) :: IO [Double] mapM_ print xs When run, I get a segmentation fault error. That is unsurprising, since the function 'randoms' produces an infinite list. Suppose I wanted to print out only the first ten values of xs. How could I do that? xs has type IO [Double], and I think I want a variable of type [IO Double]. What operators exist to convert between the two.
Tags (comma-separated)
Save Edits
Cancel