Skip to content

Instantly share code, notes, and snippets.

@unclechu
Created October 25, 2016 18:26
Show Gist options
  • Save unclechu/c34e8c7a6acffd1820d0f6f7057f8ed9 to your computer and use it in GitHub Desktop.
Save unclechu/c34e8c7a6acffd1820d0f6f7057f8ed9 to your computer and use it in GitHub Desktop.
Haskell: infinite list of random numbers to 'pure' function as an argument
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