[Haskell-beginners] reverse 'lookup'

Patrick LeBoutillier patrick.leboutillier at gmail.com
Wed Jul 7 13:28:03 EDT 2010


Hi,

The lookup function can locate something in a a-list:

   lookup :: Eq a => a -> [(a,b)] -> Maybe b

is there an easy way to do a reverse lookup:

  rlookup :: Eq b => b -> [(a,b)] -> Maybe a


or perhaps a builtin function to flip a pair:

  (a, b) -> (b, a)


Thanks,

Patrick
-- 
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada


More information about the Beginners mailing list