$ cabal install yesod
$ runhaskell helloworld.hs
| import Data.List | |
| frase = "vaca batata galinha batata coxinha macaco batata vaca batata" | |
| wordCounter frase = | |
| nub $ map (\x -> (x, length $ filter (== x) palavras)) palavras | |
| where palavras = words frase | |
| -- [("vaca",2),("batata",4),("galinha",1),("coxinha",1),("macaco",1)] |
| module DoNotation where | |
| -- without do notation | |
| -- applying only >>= | |
| monadChainSuccess1 = Just "hello" >>= \xs -> | |
| Just (xs ++ " ") >>= \ys -> | |
| Just (ys ++ "world") | |
| -- applying >>= and >> |
| # pattern matching on blocks | |
| def print_break(msg) | |
| puts '-' * 50, msg | |
| end | |
| print_break 'normal params' | |
| block = -> (one, two) { p one, two } | |
| block.call(1, 2) | |
| # 1 |