Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --1
  2. fib :: Integer -> Integer
  3. fib 0 = 1
  4. fib 1 = 1
  5. fib n = fib (n-1) + fib (n-2)
  6.  
  7. --2
  8. mdc :: Int -> Int -> Int
  9. mdc x y | (x==y) = x
  10.         | (x>y) = mdc (x-y) y
  11.         | otherwise = mdc y x
  12.  
  13. --3 REVERSE
  14. reverse2 :: [a] -> [a]
  15. reverse2 [] = []
  16. reverse2 (x:xs) = reverse2 xs ++ [x]
  17.  
  18.  
  19. --4
  20. unico :: [Integer] -> [Integer]
  21. unico (x:xs) | elem x xs = unico (apaga x xs)
  22.              | otherwise = x:unico xs
  23.  
  24. --APAGAR ELEMENTO LISTA
  25. apaga:: Integer -> [Integer] -> [Integer]
  26. apaga _ [] = []
  27. apaga y (x:xs) | y == x = apaga y xs
  28.                | otherwise = x:apaga y xs
  29.  
  30. unico2 l = [x | x<-l, length[y | y<-l, y==x]==1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement