haskell - How can i find an item in a list then return its pair? -
this question has answer here:
i have list, [('a',1),('b',2),..] i'd key value search. found lookup returns 'maybe int'. there function returns value key, , gives normal int back?
what should function in case key not in list?
if sure key in list, then
import data.maybe
and run result (i.e. maybe int) through fromjust
. you'll plain int, , when key not in list you'll exception.
Comments
Post a Comment