View Exercicios3.hs
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 |
View Aula4.hs
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 | |
View Projeto3.hs
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 |
View Exercicios3.hs
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 |
View Aula3.hs
-- 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 |
View Projeto.hs
module Projeto where | |
data Cargo = Estagiario | Programador | Coordenador | Gerente deriving Show | |
data Pessoa = Pessoa { | |
cargo :: Cargo, | |
nome :: String | |
} deriving Show | |
verSalario :: Pessoa -> Double |
View Aula2.hs
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!" |
View Aula1.hs
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] |
View yarn.lock
# 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" |