Knuth/McIlroy word count task using Haskell
✓ Published0🌍 Public
FFranklin Chen
Last edited Dec 9, 2011
Created on Dec 8, 2011
This example demonstrates a word-frequency analysis task using Haskell, showing how to compute and display the most common words from standard input. It chains data transformations through a pipeline: converting text to lowercase, replacing non-letter characters with newlines, splitting into words, and tallying counts with a hash map. The code relies on `Data.HashMap.Strict` for efficient key-value aggregation via `HashMap.fromListWith`, and uses `Data.List` for sorting and taking the top *n* results. The final output lists each word with its count, sorted in descending order of frequency. The example highlights functional composition and lazy evaluation in a concise, read-backwards data-flow style.
AI-generated description