Created
August 29, 2015 08:48
-
-
Save ulysses4ever/df6127493b141b0a1b77 to your computer and use it in GitHub Desktop.
LinqBegin60 (from PT4) on Haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
import Data.Ord (comparing) | |
import Data.Char (ord) | |
import Control.Applicative ((<$>)) | |
equating f = \a b -> f a == f b | |
thenBy ord' = concat | |
. map (sortBy ord') | |
. groupBy (equating length) | |
myPrint s = (show $ length s) ++ "-" ++ [head s] | |
main = map myPrint | |
. thenBy (comparing (ord . head)) | |
. sortBy (flip $ comparing length) | |
. map concat | |
. groupBy (equating head) | |
. sort | |
. lines | |
<$> test -- getContents -- for stdin | |
test :: IO String | |
test = return $ | |
intercalate "\n" | |
["GRPWB", "LNKF", "CBF", "D", | |
"IABW", "IAJDY", "H", "PBGNI", | |
"F", "G", "CRXC", "OYVFW"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment