Advertisement
rlucas_31c

ficha2

Oct 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dobros :: [Float] -> [Float]
  2. dobros [] = []
  3. dobros [x] = [2*x]
  4. dobros (x:y) = 2*x : (dobros y)
  5.  
  6. numOcorre :: Char -> String -> Int
  7. numOcorre x [] = 0
  8. numOcorre x (y:z) = if x == y then 1 + numOcorre x z else numOcorre x z
  9.  
  10. positivos :: [Int] -> Bool
  11. positivos [x] = if x<0 then False else True
  12. positivos (x:y) = if x<0 then False else positivos y
  13.  
  14. soPos :: [Int] -> [Int]
  15. soPos [] = []
  16. soPos (x:y) = if x <= 0 then soPos y else x:(soPos y)
  17.  
  18. --soNeg :: [Int] -> [Int]
  19. --soNeg [] = []
  20. --soNeg (x:y) = if x >= 0 then soNeg y else x:(soNeg y)
  21.  
  22. somaNeg :: [Int] -> Int
  23. somaNeg [] = 0
  24. somaNeg (x:y) =  if x < 0 then x + somaNeg y else somaNeg y
  25.  
  26. tresUlt :: [a] -> [a]
  27. tresUlt [] = []
  28. tresUlt (x:y) = if length (x:y) <= 3 then (x:y) else tresUlt y
  29.  
  30. segundos :: [(a,b)] -> [b]
  31. segundos [] = []
  32. segundos (x,y) = y:segundos (x:y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement