14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ズンドコキヨシ with Haskell

14
Last updated at Posted at 2016-03-11

ズンドコキヨシ 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 = "キ・ヨ・シ!"

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

14
12
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?