Skip to content

Instantly share code, notes, and snippets.

@rikukissa
Created March 6, 2014 18:08
Show Gist options
  • Select an option

  • Save rikukissa/9395823 to your computer and use it in GitHub Desktop.

Select an option

Save rikukissa/9395823 to your computer and use it in GitHub Desktop.
phoneBook =
[("betty","555-2938")
,("bonnie","452-2928")
,("patsy","493-2928")
,("lucille","205-2928")
,("wendy","939-8282")
,("penny","853-2492")
]
getNumberByName :: (Eq a) => a -> [(a, c)] -> Maybe c
getNumberByName name [] = Nothing
getNumberByName name ((person, phone):list) = if name == person
then Just phone
else getNumberByName name list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment