Skip to content

Instantly share code, notes, and snippets.

@pasberth
Last active December 29, 2015 10:49
Show Gist options
  • Save pasberth/7659927 to your computer and use it in GitHub Desktop.
Save pasberth/7659927 to your computer and use it in GitHub Desktop.
--ちんちんっぽいことするやつ
import System.Random
chimpo :: String -> IO String
randomString :: String -> IO String
chimpo c = do s <- randomString c
if take 4 c == "ABCDE"
then return $ c ++ ("なんか終わりました" ++ (show (length c )))
else chimpo s
randomString s = getStdRandom (randomR ((0, 4)::(Int,Int))) >>= \r -> case r of
0 -> return ("A" ++ s)
1 -> return ("B" ++ s)
2 -> return ("C" ++ s)
3 -> return ("D" ++ s)
4 -> return ("E" ++ s)
main = do x1 <- randomString ""
x2 <- chimpo x1
putStrLn x2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment