The Dabsong Conshirtoe

技術系の話を主にします。

Haskell占い

あけましておめでとうございます。
去年はpython占いしたので今年はHaskell占いします。

-- ghciで実行(letとか省いてます)
import System.Random
choice :: [String] -> Int -> String
choice choices seed = (choices !!) . fst $ randomR (0, length choices - 1) $ mkStdGen seed
putStrLn $ choice ["大凶", "凶", "大吉", "中吉", "小吉", "吉", "マジ吉"] 2014
> 中吉

いいですね!
今年もよろしくお願いします。