Created
March 17, 2016 00:51
-
-
Save washingtonsoares/238641ec0a465fbf638e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
qtd_numero_iguais :: Int -> Int -> Int -> Int | |
qtd_numero_iguais a b c = if (a == b && b==c) then 3 else if (a==b || b ==c || a==c) then 2 else 0 | |
--b*b > 4*a*c | |
duas_raizes a b c = b*b > 4*a*c | |
--b*b == 4*a*c | |
uma_raiz a b c = b*b == 4*a*c | |
--b*b < 4*a*c | |
nenhuma_raiz a b c = b*b < 4*a*c | |
quantas_raizes :: Int -> Int -> Int -> Int | |
quantas_raizes a b c = if(duas_raizes a b c) then 2 else if(uma_raiz a b c) then 1 else 0 | |
eh_par :: Int -> Bool | |
eh_par nro = mod nro 2 == 0 | |
--eh_par nro = if mod nro 2 == 0 then True else False | |
eh_impar :: Int -> Bool | |
eh_impar nro = not (eh_par nro) | |
menor_dois :: Int -> Int -> Int | |
menor_dois x y = if(x < y) then x else y | |
menor_tres :: Int -> Int -> Int -> Int | |
menor_tres x y z = if (x < y && x < z) then x else if (y < z) then y else z | |
not1 :: Bool -> Bool | |
not1 x = not x | |
not2 :: Bool -> Bool | |
not2 x = if(x == True) then False else True | |
and1 :: Bool -> Bool -> Bool | |
and1 p q = p && q | |
and2 :: Bool -> Bool -> Bool | |
and2 p q = if(p == True && p == q) then True | |
else False | |
or1 :: Bool -> Bool -> Bool | |
or1 p q = p || q | |
or2 :: Bool -> Bool -> Bool | |
or2 p q = if(p /= q) then True | |
else if(p == True && p == q) then True | |
else False | |
nand1 :: Bool -> Bool -> Bool | |
nand1 p q = not(p && q) | |
nand2 :: Bool -> Bool -> Bool | |
nand2 p q = not(and1 p q) | |
nor1 :: Bool -> Bool -> Bool | |
nor1 p q = not (p || q) | |
nor2 :: Bool -> Bool -> Bool | |
nor2 p q = not (or1 p q) | |
xor1 :: Bool -> Bool -> Bool | |
xor1 p q = not(p && q) && (p || q) | |
xor2 :: Bool -> Bool -> Bool | |
xor2 p q = if(p == True && q == True) then False | |
else if(p == True && q == False) then True | |
else if(p == False && q == True) then True | |
else False | |
xnor1 :: Bool -> Bool -> Bool | |
xnor1 p q = not (not(p && q) && (p || q)) | |
xnor2 :: Bool -> Bool -> Bool | |
xnor2 p q = not(xor1 p q) | |
classifica_triangulo :: Int -> Int -> Int -> String | |
classifica_triangulo a b c = if (a == b && b==c) then "Equilatero" else if (a==b || b ==c || a==c) then "isoceles" else "Escaleno" | |
eh_triangulo :: Int -> Int -> Int -> String | |
eh_triangulo a b c = if(a+b > c && b+c > a && a+c > b) then classifica_triangulo a b c else "Nao eh um triangulo valido" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment