Skip to content

Instantly share code, notes, and snippets.

@jutememo
Created October 31, 2009 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jutememo/222989 to your computer and use it in GitHub Desktop.
Save jutememo/222989 to your computer and use it in GitHub Desktop.
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