This is a function to generate a list of given number of random numbers within a range, but I'm confused on how to call on this function. I think a seed is needed for StdGen, but really appreciate if someone can tell how exactly to call this function. randomList :: (Random a) => (a,a) -> Int -> StdGen -> [a]randomList bnds n = take n . randomRs bnds 解决方案 Sample:main :: IO ()main = do g <- getStdGen print (randomList (1, 100) 5 g :: [Integer])will output e.g.[42,42,15,7]The g is the random number generator, in this case the "global random number generator".Here's the documentation 这篇关于如何调用此Haskell函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-18 11:48