Mercurial > hg > Members > toma > osc2013
view prog/record.hs @ 10:bf2da4395b5f default tip
add example
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 06 Jul 2013 15:04:57 +0900 |
parents | eea79db7cd9e |
children |
line wrap: on
line source
-- レコード構文を使わない場合 data Person = Person String String Int Float String String deriving (Show) firstName :: Person -> String firstName (Person firstname _ _ _ _ _) = firstname lastName :: Person -> String lastName (Person _ lastname _ _ _ _) = lastname age :: Person -> Int age (Person _ _ age _ _ _) = age height :: Person -> Float height (Person _ _ _ height _ _) = height phoneNumber :: Person -> String phoneNumber (Person _ _ _ _ number _) = number flavor :: Person -> String flavor (Person _ _ _ _ _ flavor) = flavor -- レコード構文 data Person = Person { firstName :: String , lastName :: String , age::Int , height :: Float , phoneNumber :: String , flavor :: String } deriving (Show)