Skip to content

Instantly share code, notes, and snippets.

@washingtonsoares
Created April 7, 2016 01:14
Show Gist options
  • Save washingtonsoares/f6809ac396d21b5a7b6ee4dcaa05b360 to your computer and use it in GitHub Desktop.
Save washingtonsoares/f6809ac396d21b5a7b6ee4dcaa05b360 to your computer and use it in GitHub Desktop.
null1 :: [a] -> Bool
null1 lista = if(length lista > 0) then False else True
safetail1 :: [Int] -> [Int]
safetail1 lista = if(null lista == True) then [] else tail lista
safetail2 :: [Int] -> [Int]
safetail2 lista
| otherwise = tail lista
| null lista == True = []
terceiro :: [Int] -> Int
terceiro lista = head (tail(tail lista))
iniciais :: String -> String -> (Char, Char)
iniciais first_name last_name = (head first_name, head last_name)
fatorial :: Int -> Int
fatorial numero = product[1..numero]
media :: [Float] -> Float
media lista = (sum lista)/ fromIntegral((length lista))
ultimo :: [a] -> a
ultimo lista = last lista
inicio1 :: [a] -> [a]
inicio1 lista = take ((length lista) - 1) lista
aprovado :: (String, [Float]) -> (String, String)
aprovado (nome, notas) = if(media notas > 60) then (nome, "Aprovado") else (nome, "Reprovado")
atualiza :: Int -> [Int] -> [Int]
atualiza numero lista = if(elem numero lista) then lista else numero:lista
media2 :: [Float] -> Float
media2 lista = (sum lista - minimum lista)/ fromIntegral((length lista)-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment