Created
May 5, 2016 00:58
-
-
Save washingtonsoares/203d5d1dedf301b24202d93745d4b4c2 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
comprimento :: [Char]->Int | |
comprimento [] = 0 | |
comprimento (p:r) = 1 + comprimento(r) | |
pertence :: Int-> [Int] -> Bool | |
pertence x [] = False | |
pertence x (p:r) = if(x == p) then True else pertence x (r) | |
maior :: [Int]->Int | |
maior [p] = p | |
maior (p:s:r) = if(p > s) then maior(p:r) else maior(s:r) | |
iguais :: [Int]->[Int]->Bool | |
iguais [] [] = True | |
iguais (p1:r1) (p2:r2) = if(p1 /= p2) then False else iguais (r1) (r2) | |
nesimo :: Int->[Int]->Int | |
nesimo 1 (p:_) = p | |
nesimo x (p:r) = nesimo (x-1) (r) | |
insere_ordenado :: Int->[Int]->[Int] | |
insere_ordenado x [] = [x] | |
insere_ordenado x (p:r) = if(x < p) then (x:p:r) else p:insere_ordenado x r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment