uniq_c contains a counter of the number of lines that appear in the list of lines concatenated with a space for a specific line:
*A> uniq_c ["The","quick","brown","fox","fox"]
["1 The","1 quick","1 brown","2 fox"]
*A> uniq_c $ ["The","quick","brown","fox","fox","fox"] ++ (replicate 100 "fox")
[" 1 The"," 1 quick"," 1 brown","103 fox"]
uniq_c'contains a list of tuples (string,count).
tam finds the largest counter (which will be the last occurrence for any particular row).
nl discards the counts so that the counts are correctly justified.
*A> mapM_ putStrLn $ uniq_c $ ["The","quick","brown","fox","fox","fox"] ++ (replicate 100 "fox")
1 The
1 quick
1 brown
103 fox
source
share