source: https://www.hackerrank.com/challenges/30-dictionaries-and-maps
-- Enter your code here. Read input from STDIN. Print output to STDOUT
module Main whereimport qualified Data.Map as Map
import qualified Control.Monad as Monad
list2tuple :: [a] -> (a, a)
list2tuple (a:b:xs) = (a,b)
lookupMap :: Map.Map String String -> String -> String
lookupMap map key = let val = Map.lookup key map
in case val of
Just v -> key ++ "=" ++ v
Nothing -> "Not found"
main :: IO()
main = do
count <- getLine >>= return.read :: IO Int
map <- Monad.replicateM count getLine >>= return.Map.fromList.fmap (list2tuple.words)
getContents >>= return.words >>= mapM (putStrLn.lookupMap map)
return ()