Skip to content

Instantly share code, notes, and snippets.

@rxw1
Created November 12, 2020 02:04
Show Gist options
  • Select an option

  • Save rxw1/6c1ccb788331c8ca6ba7a92338afd692 to your computer and use it in GitHub Desktop.

Select an option

Save rxw1/6c1ccb788331c8ca6ba7a92338afd692 to your computer and use it in GitHub Desktop.

Revisions

  1. @rwilhelm rwilhelm created this gist Nov 12, 2020.
    7 changes: 7 additions & 0 deletions wordfreq.hs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import Data.List
    import Data.Ord

    main = interact $ (=<<) (\x -> show (length x) ++ " " ++ head x ++ "\n")
    . sortBy (flip $ comparing length)
    . group . sort
    . words