Skip to content

Instantly share code, notes, and snippets.

@lsmag
Created April 16, 2014 14:43
Show Gist options
  • Save lsmag/10887190 to your computer and use it in GitHub Desktop.
Save lsmag/10887190 to your computer and use it in GitHub Desktop.
map (negate . round . (* 3)) [2.77, 3.02, 5.05, 2.221]
-- negate . round . (* 3)
-- 1)
-- (* 3) ... em Haskell, todos os operadores são funções (e todas as funções são curryied)
-- x * y == (* x y)
-- logo, (* n) == \x -> (* n x)
-- negate . round . (\x -> 3 * x)
-- 2)
-- o operador "." é de composição... basicamente recebe duas funções e
-- retorna uma outra que é a composição dessas. Por exemplo:
-- f . g == \x -> f (g x)
-- negate . (\x -> round (3 * x))
-- \x -> negate (round (3 * x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment