Skip to content

Instantly share code, notes, and snippets.

@cosmo0920
Last active December 20, 2015 21:49
Show Gist options
  • Save cosmo0920/6200485 to your computer and use it in GitHub Desktop.
Save cosmo0920/6200485 to your computer and use it in GitHub Desktop.
ランダム文字列生成
import System.Random
generateRandString :: (RandomGen g) => g -> [String]
generateRandString gen =
[randomRs ('A', 'z') gen | x <- [0..]]
randString :: IO String
randString = do
randomGen <- newStdGen
let string = concat $ generateRandString randomGen
return string
main :: IO ()
main = do
string <- randString
print $ take 50 string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment