Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main :: IO () -- This says that main is an IO action.
- main = return ()
- data Auto = Auto {
- nombre :: String,
- nafta :: Int,
- velocidad :: Int,
- match :: String,
- truco :: String} deriving Show
- rochaMcqueen = Auto "rochaMcqueen" 300 0 "Ronco" "deReversa"
- --bianker Auto = Auto "bianker" 500 20 "Tinch" "impresionar"
- --gushtav Auto = Auto "gushtav" 200 130 "PetiLaLinda" "nitro"
- --rodra Auto = Auto "rodra" 0 50 "taisa" "fingirAmor"
- verTruco :: Auto -> String
- verTruco (Auto _ _ _ _ x) = x
- impresionar :: Auto -> Auto
- impresionar unAuto = unAuto { velocidad = (* velocidad unAuto) 2 }
- nitro :: Auto -> Auto
- nitro unAuto = unAuto { velocidad = (+ velocidad unAuto) 15}
- fingirAmor :: Auto -> Auto
- fingirAmor unAuto = unAuto { match = cambiarNombre }
- cambiarNombre :: String -> String
- cambiarNombre x = x
- hacerTruco :: Auto -> Auto
- hacerTruco unAuto | verTruco unAuto == "impresionar" = impresionar unAuto
- | verTruco unAuto == "nitro" = nitro unAuto
- | verTruco unAuto == "fingirAmor" = fingirAmor unAuto
- | otherwise = unAuto
- obtenerMatch :: Auto -> String
- obtenerMatch (Auto _ _ _ x _ ) = x
- cantVocales :: Auto -> Int
- cantVocales unAuto = length (filter vocales (obtenerMatch unAuto))
- vocales :: Char -> Bool
- vocales letra = letra == 'a' || letra == 'e' || letra == 'i' || letra == 'o' || letra == 'u'
- modificarVelocidad :: Auto -> Auto
- modificarVelocidad unAuto | cantVocales unAuto >= 1 && cantVocales unAuto <=2 = unAuto { velocidad = velocidad + 15}
- | cantVocales unAuto >= 3 && cantVocales unAuto <=4 = unAuto { velocidad = velocidad + 20}
- | cantVocales unAuto >= 4 = unAuto { velocidad = velocidad unAuto + 30}
- | otherwise = unAuto
- --puedeHacerTruco unAuto x = unAuto { truco verificarTruco x}
- --verificarTruco x = unAuto { nafta > 0 && velocidad < 100}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement