Letter frequency: Difference between revisions

→‎{{header|Haskell}}: Standard operators perhaps now preferable to Control.Arrow ?
(added RPL)
(→‎{{header|Haskell}}: Standard operators perhaps now preferable to Control.Arrow ?)
Line 3,608:
=={{header|Haskell}}==
Short version:
<syntaxhighlight lang="haskell">import Data.List (group, sort)
 
import Control.Arrow ((&&&))
main :: IO ()
main = interact (show . mapfmap ((,) . head &&&<*> length) . group . sort)</syntaxhighlight>
 
or, as an alternative to sorting and grouping the whole string, we could use some kind of container as the accumulator for a single fold, for example:
9,655

edits