Edited at

ズンドコキヨシ with Haskell

More than 3 years have passed since last update.

ズンドコキヨシ with Perl6

をHaskellでやってみました。もうちょっと短くなるような気もします。

import           Control.Monad

import System.Random

data Sound = Z | D | K deriving (Eq, Ord, Show)

main :: IO ()
main = genSound >>= go [] >> putStr "\n"
where
go (D:Z:Z:Z:Z:_) _ = putStr (showZDK K)
go xs x = putStr (showZDK x) >> genSound >>= go (x:xs)

genSound :: IO Sound
genSound = (!!) [Z,D] <$> getStdRandom (randomR (0,1))

showZDK :: Sound -> String
showZDK Z = "ズン"
showZDK D = "ドコ"
showZDK K = "キ・ヨ・シ!"

ところでズンドコキヨシって何?