Skip to content

Instantly share code, notes, and snippets.

@motokiee
Created October 14, 2015 04:52
Show Gist options
  • Save motokiee/80db477610fee752c8cb to your computer and use it in GitHub Desktop.
Save motokiee/80db477610fee752c8cb to your computer and use it in GitHub Desktop.
ちょっとだけHaskellのモジュールの勉強した。ちょっと面倒な処理をこの少ない行にまとめられるのスゴい #CodePiece
import Data.List
import qualified Data.Map as M
numUniques :: (Eq a) => [a] -> Int
numUniques = length . nub
wordNums :: String -> [(String,Int)]
wordNums = map (\ws -> (head ws, length ws)) . group . sort . words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment