Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- store:: Map.Map String Integer
- store = Map.fromList [("x", 2), ("y", 3)]
- main:: IO()
- main = do
- putStr "{"
- Map.foldrWithKey (\k v b -> do {putStr (k ++ " → " ++ (show v)); b}) (return()) store
- putStr "}"
- -- This prints {x → 2y → 3}
- -- I want {x → 2, y → 3}
- -- I was trying something like this:
- -- Map.foldrWithKey (\k v b -> do {putStr (k ++ " → " ++ (show v)); if b!="" then b else putStr ", "; b}) (return()) store
- -- I'm not really sure how to do putStr (k ++ " → " ++ (show v)) for the first element
- -- then do {putStr (", " ++ k ++ " → " ++ (show v)); b}) (return()) store for all the elements after
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement