Skip to content

Instantly share code, notes, and snippets.

@krdlab
Created April 5, 2017 06:38
Show Gist options
  • Save krdlab/986dd27acfa9273ffe60a50207c52617 to your computer and use it in GitHub Desktop.
Save krdlab/986dd27acfa9273ffe60a50207c52617 to your computer and use it in GitHub Desktop.
職場の同僚に教えてもらったネタ
import System.Random (randomRIO)
zndk :: [String]
zndk = ["ズン", "ドコ"]
kiyoshi :: IO ()
kiyoshi = go 0
where
go c = rand zndk >>= \v -> putStr v >> go' c v
go' c "ズン" = go (c + 1)
go' c "ドコ"
| c < 4 = go 0
| otherwise = putStrLn "きよし"
rand :: [a] -> IO a
rand xs = (!!) xs <$> randomRIO (0, length xs - 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment