

Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Haskell - Haskell
Tipologia: Notas de estudo
1 / 3
Esta página não é visível na pré-visualização
Não perca as partes importantes!


criarLista :: Int -> [Int] criarLista 0 = [] criarLista x = [0..(x -1 )]
addTermoInit :: [Int] -> Int -> [Int] addTermoInit [] i = [i] addTermoInit l i = (i:l) -- [i] ++ l
addTermoFim :: [Int] -> Int -> [Int] addTermoFim [] i = [i] addTermoFim l i = l ++ [i]
verif :: [Int]-> Int -> [Int] verif [] x = [x] verif (h:t) x |h == x = (h:t) |otherwise= (h:(verif t x))
verifBool :: [Int] -> Int -> Bool verifBool [] x = False verifBool (h:t) x |h==x = True |otherwise = verifBool t x
concatTeste :: [Int] -> [Int] -> [Int] contatTeste [] l = l contatTeste m [] = m concatTeste (h:t) l = (h:(concatTeste t l))
reverseTeste :: [Int] -> [Int] reverseTeste [] = [] reverseTeste (h:t) = (reverseTeste t ) ++ [h]
repita :: Int -> Int-> [Int] repita 0 x = [] repita y x = [x] ++ (repita (y-1) x)
tam :: [Int] -> Int tam [] = 0 tam (h:t) = 1+(tam t)
takeTeste :: Int -> [Int] -> [Int] takeTeste 0 l = [] takeTeste x [] = [] takeTeste x (h:t) = [h] ++ (takeTeste(x-1) t )
dropTeste :: Int -> [Int] -> [Int] dropTeste 0 l = l dropTeste x [] = [] dropTeste x (h:t) = (dropTeste (x-1) t)
rotate :: Int ->[Int] -> [Int] rotate 0 l = l rotate x [] = []
rotate x (h:t) = (rotate (x-1) t) ++ (reverseTeste [h])
menor :: Int -> [Int] -> [Int] menor x [] = [] menor x (h:t) |h < x = (h: (menor x t)) | otherwise = (menor x t)
palindromo :: String -> Bool palindromo "" = True palindromo (h:[]) = True palindromo (h:t) | h == last t = palindromo (drop 1 (take (length t ) (h:t))) |otherwise = False
reverseString :: String -> String reverseString "" = "" reverseString (h:t) = (reverseString t ) ++ [h]
incrementa :: Int -> Int incrementa x = x+
increLista :: [Int] -> [Int] increLista [] = [] increLista (h:t) = (incrementa h):increLista t
somaListas :: [Int] -> [Int] ->[Int] somaListas [] [] = [] somaListas [] l = l somaListas l [] = l somaListas (h:t) (a:b) =( h + a ) : somaListas t b
aPorx :: String -> String aPorx "" = "" aPorx (h:t) | h == 'a' = ('x':aPorx t) |otherwise = h:(aPorx t)
tirarUlt :: Int->[Int] -> [Int] tirarUlt x [] = [] tirarUlt 0 (h:t) = [] tirarUlt x (h:t) = h: (take ((length t )-1) t)
primUltimo :: String-> String primUltimo "" = "" primUltimo (h:t) = last t : ((take ((length t )-1)t) ++ [h])
del_posicao :: Int -> [Int] -> [Int] del_posicao x [] = [] del_posicao 0 (h:t) = t