Skip to content

Instantly share code, notes, and snippets.

View bitmaybewise's full-sized avatar
👋

Hercules Merscher bitmaybewise

👋
View GitHub Profile
@bitmaybewise
bitmaybewise / README.md
Created August 12, 2014 23:16
Yesod HelloWorld

Yesod HelloWorld

$ cabal install yesod

$ runhaskell helloworld.hs

@bitmaybewise
bitmaybewise / WordCounter.hs
Last active August 29, 2015 14:08
Um contador de palavras numa frase em Haskell
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)]
@bitmaybewise
bitmaybewise / DoNotation.hs
Created November 22, 2014 13:18
Playing with Haskell monads and do notation
module DoNotation where
-- without do notation
-- applying only >>=
monadChainSuccess1 = Just "hello" >>= \xs ->
Just (xs ++ " ") >>= \ys ->
Just (ys ++ "world")
-- applying >>= and >>
@bitmaybewise
bitmaybewise / pattern_matching.rb
Last active August 29, 2015 14:14
Ruby's pattern matching
# 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