Skip to content

Instantly share code, notes, and snippets.

@shigemk2 shigemk2/doll.hs
Created Feb 4, 2015

Embed
What would you like to do?
-- 括弧を省略して$に書き換えることができちゃう
main = do
print $ sum (filter (> 10) (map (*2) [2..10]))
print $ sum $ filter (> 10) (map (*2) [2..10])
print $ sum $ filter (> 10) $ map (*2) [2..10]
-- $ は関数適用それ自身を関数として扱えるようにするために使えます
print $ map ($ 3) [(4+), (10*), (^2), sqrt]
-- print $ [(4+), (10*), (^2), sqrt] -- これは出来ない
print $ take 10 $ map (+ 3) [1..]
print $ map ($ 3) $ take 10 $ map (+) [1..]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.