
On Mon, 01 Jun 2015 16:10:47 +0000
Alex Hammel
extract :: [String] -> [(String,b)] -> ([String],[b]) extract xs assocs = let xs' = map uppercase xs eithers = map (\x -> lookupEither x assocs) xs' -- spoilers: same as [ lookupEither x assocs | x <- xs' ] in partitionEithers eithers
This differs slightly from your algorithm in that it returns '(["BAR"],[1]), where yours would return (["Bar"],[1]). If preserving the original case in the output, I would either write a
ok. big surprise, i like your version much better. however, i'm unclear why you didn't just use eithers = map (\x -> lookupEither (uppercase x) assocs) xs instead of mapping everything to uppercase first. meanwhile i need to get with the list comprehension program. i use python list comprehensions all the time, and yet i continue to use map in haskell. how weird is that ? Brian