Slipkorn

tp

Apr 22nd, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sigla :: [[Char]]->[Char]
  2. sigla x = [head n | n<-x]
  3.  
  4. vocales = ['a','e','i','o','u','A','E','I','O','U']
  5.  
  6. esVocal :: Char->Bool
  7. esVocal x = elem x vocales
  8.                  
  9. cantvocales :: [Char]->Int
  10. cantvocales x = length [m | m <- x, esVocal m]
  11.  
  12. mitletras :: [Char]->Int
  13. mitletras x = div (length x) 2
  14.  
  15. masVocales :: [Char]->Bool
  16. masVocales cad = mitletras cad < cantvocales cad
  17.                          
  18. interseccion :: Eq a =>[a]->[a]->[a]
  19. interseccion x y = [ n | n<-x, m<-y,n==m]
  20.  
  21. nombre :: ([Char],Int,Char,[[Char]]) -> [Char]
  22. nombre  (_,_,_,sucursales) = head sucursales
  23.  
  24. casaMatriz :: ([Char],Int,Char,[[Char]]) -> Bool
  25. casaMatriz (_,_,_,sucursales) = (last sucursales) == "Casa Matriz"
  26.  
  27. paraJubilarse :: ([Char],Int,Char,[[Char]]) -> Int
  28. paraJubilarse (_,edad,sexo,_) | sexo == 'M' = 65 - edad
  29.                   | sexo == 'F' = 60 - edad
  30.                   | otherwise = error "Sexo incorrecto"
  31.  
  32. mismaSucursal :: ([Char],Int,Char,[[Char]]) -> ([Char],Int,Char,[[Char]]) -> Bool
  33. mismaSucursal (_,_,_,sucursales) (_,_,_,sucursales2) = not $ null $ interseccion sucursales sucursales2
  34.  
  35. distsexo :: ([Char],Int,Char,[[Char]])->([Char],Int,Char,[[Char]])->Bool
  36. distsexo (_,_,sexo,_) (_,_,sexo2,_) = not $ sexo == sexo2
  37.  
  38. salirjuntos :: ([Char],Int,Char,[[Char]])->([Char],Int,Char,[[Char]])->Bool
  39. salirjuntos x y = (distsexo x y) && (jub x y) && (mismsucmat x y)
  40.           where jub a b = (paraJubilarse a > 10) && (paraJubilarse b > 10)
  41.             mismsucmat c d = (mismaSucursal c d) || estamatriz c d
  42.             estamatriz e f = (casaMatriz e || casaMatriz f)
Advertisement
Add Comment
Please, Sign In to add comment