Unique characters: Difference between revisions
→{{header|Haskell}}: Preferred Data.Map.Strict methods to a list comprehension
(→{{header|Haskell}}: Preferred Data.Map.Strict methods to a list comprehension) |
|||
Line 624:
uniqueChars :: [String] -> String
uniqueChars
M.keys . M.filter (1 ==)
. foldr (M.unionWith (+) . charCounts) M.empty
charCounts :: String -> M.Map Char Int
charCounts =
M.empty
▲ updatedCharCount c = M.insertWith (+) c 1
--------------------------- TEST -------------------------
|