Unique characters: Difference between revisions

Content added Content deleted
Line 582: Line 582:
Or folding the strings down to a hash of character frequencies:
Or folding the strings down to a hash of character frequencies:
<lang haskell>import qualified Data.Map.Strict as M
<lang haskell>import qualified Data.Map.Strict as M



--------- UNIQUE CHARACTERS FROM A LIST OF STRINGS -------
--------- UNIQUE CHARACTERS FROM A LIST OF STRINGS -------


uniqueChars :: [String] -> String
uniqueChars :: [String] -> String
uniqueChars ks =
uniqueChars xs =
[ k
[ k
| (k, v) <-
| (k, v) <-
Line 594: Line 593:
(flip (foldr (flip (M.insertWith (+)) 1)))
(flip (foldr (flip (M.insertWith (+)) 1)))
M.empty
M.empty
ks,
xs,
1 == v
1 == v
]
]