I saw Brad Fitzpatrick's post on anagram twin names and decided to join in the golf. Weeee!
import Control.Arrow ( first , second , (&&&) , (***) )
import List ( sortBy , groupBy , intersperse )
main = interact $ unlines
. map ( uncurry (++) )
. map ( ( ++ " : " ) . fst . head &&& concat . intersperse ", " . map snd )
. filter ( (> 1) . length )
. groupBy ( curry $ uncurry (==) . (***) fst fst )
. sortBy (curry $ uncurry compare . (***) fst fst )
. map ( sortBy compare &&& id )
. filter ( not . null )
. map ( fst . break (== ' ') )
. lines
hehehe
No comments:
Post a Comment