Skip to content

Instantly share code, notes, and snippets.

@akanehara
Created October 17, 2013 01:46
Show Gist options
  • Save akanehara/7018029 to your computer and use it in GitHub Desktop.
Save akanehara/7018029 to your computer and use it in GitHub Desktop.
標準ライブラリに on あるの知らなかった
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