04/02/15 22:53
>>22
depositだけ実装。
============================
module Main where
import Data.FiniteMap
import Data.Maybe
type Database = FiniteMap Int Int
-- errors are silently ignored.
deposit :: Database -> (Int, Int) -> Database
deposit db (nm, mon)
= fromMaybe db (lookupFM db nm >>= return . addToFM db nm . (+ mon))
testDB :: Database
testDB = listToFM [(0, 100), (1,1000), (2, 300)]
data Cmd = Deposit Int Int | Withdraw Int Int | Print | Error
deriving Read
============================
続く