Created
October 31, 2009 08:48
-
-
Save jutememo/222989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
data Person = Person { name, address :: String} deriving Show | |
ps = [ Person "Tarou" "Tokyo" | |
, Person "Jirou" "Osaka" | |
, Person "Saburou" "Nagoya" | |
] | |
getAddress n ps = case find ((== n) . name) ps of | |
Just x -> address x | |
Nothing -> n ++ " ha imasen" | |
main = mapM_ (putStrLn . flip getAddress ps) ["Tarou","Hanako"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment