Skip to content

Instantly share code, notes, and snippets.

View romulogarofalo's full-sized avatar

Rômulo Garofalo romulogarofalo

View GitHub Profile
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.0.0-beta.35":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8"
integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==
dependencies:
"@babel/highlight" "^7.0.0"
@romulogarofalo
romulogarofalo / Aula1.hs
Created August 14, 2019 02:46
Aula1. todo o conteúdo do primeiro video ensinando Haskell
module Aula1 where
adicionaDois :: Int -> Int
adicionaDois x = x + 2
somaTres :: Int -> Int -> Int -> Int
somaTres x y z = x + y + z
adicionaQuatro :: [Int] -> [Int]
adicionaQuatro xs = [x + 4 | x <- xs, (mod x 2) /= 0]
@romulogarofalo
romulogarofalo / Aula2.hs
Created August 14, 2019 02:50
Aula2. com todo o conteúdo mostrado no video 2 ensinando Haskell
module Aula2 where
data Dia = Segunda | Terca | Quarta | Quinta | Sexta | Sabado | Domingo
-- :t Segunda
diaDoQue :: Dia -> String
diaDoQue Sabado = "Festa :D"
diaDoQue Domingo = "Ressaca :("
diaDoQue _ = "Trabalho!"
@romulogarofalo
romulogarofalo / Projeto.hs
Created August 14, 2019 02:52
Aula2Projeto. todo o conteúdo do projeto criado para o video de aula2
module Projeto where
data Cargo = Estagiario | Programador | Coordenador | Gerente deriving Show
data Pessoa = Pessoa {
cargo :: Cargo,
nome :: String
} deriving Show
verSalario :: Pessoa -> Double
-- hj na aula 3 vamos falar de, funcoes de alta ordem, currying, 3 famoso que todo javascriptero usa, $, |>
module Aula3 where
-- (\x -> x*2) 4
-- (\x xs -> x : reverse xs) 'A' "UOIE"
-- FUNÇÕES DE ALTA ORDEM
module Exercicios4 where
-- 1
media :: [Double] -> Double
media z = (foldl (\x y -> x + y) 0 z)
-- 2
pares :: [Int] -> [Int]
pares x = filter (\y -> mod y 2 == 0) x
module Projeto3 where
data Cargo = Estagiario | Programador | Coordenador | Gerente deriving Show
data Pessoa = Pessoa {cargo :: Cargo, nome :: String} deriving Show
verSalario :: Pessoa -> Double
verSalario (Pessoa Estagiario _) = 1500
verSalario (Pessoa Programador _) = 5750.15
verSalario (Pessoa Coordenador _) = 8000
verSalario (Pessoa Gerente _) = 10807.20
module Aula4 where
-- polimorfismo parametrico
-- lembrar de falar de kind * -> *
data Coisa a = UmaCoisa a | DuasCoisas a a | ZeroCoisa
data Arvore a = Nulo |
Leaf a |
Branch a (Arvore a) (Arvore a) deriving Show
module Exercicios3 where
media:: [Double] -> Double
media xs = foldl (\x y -> x + y) 0.0 xs / foldl (\x _ -> x + 1) 0.0 xs
data Correncia = Dolar | Real deriving (Show, Eq)
data Dinheiro = Dinheiro { valor:: Double, correncia:: Correncia } deriving Show
converteToDolar :: Dinheiro -> Dinheiro