Created
October 17, 2013 01:46
-
-
Save akanehara/7018029 to your computer and use it in GitHub Desktop.
標準ライブラリに on あるの知らなかった
This file contains hidden or 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.Function | |
import Data.List | |
data Person = Person { name :: String, age :: Int } deriving Show | |
people = [ | |
Person "Joe" 16 | |
, Person "Mary" 8 | |
, Person "Bob" 9 | |
, Person "Mike" 8 | |
, Person "Alice" 11 | |
] | |
groupBy ((==) `on` age) . sortBy (compare `on` age) $ people |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment