“Just the place for a Snark! I have said it twice:
That alone should encourage the crew.
Just the place for a Snark! I have said it thrice:
What I tell you three times is true.”
-- ========== nonsense.hs ==========
#! /usr/bin/haskell
import Data.List
statementList =
[»I'm very much afraid I didn't mean anything but nonsense!«
,»Just the place for a Snark!«
,»Just the place for a Snark!«
,»6 * 7 = 42«
,»I'm very much afraid I didn't mean anything but nonsense!«
,»6 * 7 = 39«
,»6 * 7 = 39«
,»Just the place for a Snark!«
,»6 * 7 = 42«
,»I'm very much afraid I didn't mean anything but nonsense!«
,»6 * 7 = 39«
]
atLeastThrice :: [String] -> [String]
atLeastThrice sL = [head grp | grp <- group $ sort sL, length grp >= 3]
-- ========== Result ==========
ghci> :load nonsense.hs
ghci> atLeastThrice statementList
[»6 * 7 = 39«,»I'm very much afraid I didn't mean anything but nonsense!«,»Just the place for a Snark!«]
|