This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Projeto where | |
data Cargo = Estagiario | Programador | Coordenador | Gerente deriving Show | |
data Pessoa = Pessoa { | |
cargo :: Cargo, | |
nome :: String | |
} deriving Show | |
verSalario :: Pessoa -> Double |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |