Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
11
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@fujimura

ズンドコキヨシ with Haskell

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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
11
Help us understand the problem. What are the problem?