Created
October 25, 2016 18:26
-
-
Save unclechu/c34e8c7a6acffd1820d0f6f7057f8ed9 to your computer and use it in GitHub Desktop.
Haskell: infinite list of random numbers to 'pure' function as an argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.Random (newStdGen, randomRs) | |
someFunc salts x = | |
map mapper $ take 20 salts | |
where mapper = (+ x) . floor . (* 10) | |
main :: IO () | |
main = do | |
gen <- newStdGen | |
let randoms = randomRs (0 :: Float, 1 :: Float) gen | |
print $ someFunc randoms 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment