无重复版本:
randomN :: Int -> IO [Int]
randomN n = do
gen <- getStdGen
return $ take n . nub $ randomRs (0, n-1) gen
有重复版本:
randomN' :: Int -> IO [Int]
randomN' n = do
gen <- getStdGen
return $ take n $ randomRs (0, n-1) gen
无重复版本:
randomN :: Int -> IO [Int]
randomN n = do
gen <- getStdGen
return $ take n . nub $ randomRs (0, n-1) gen
有重复版本:
randomN' :: Int -> IO [Int]
randomN' n = do
gen <- getStdGen
return $ take n $ randomRs (0, n-1) gen