This file contains 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
--Ejercicio 1: fibonacci | |
fibonacci 1 = 1 | |
fibonacci 2 = 1 | |
fibonacci x = fibonacci (x-1) + fibonacci(x-2) | |
--Ejercicio 2: pertenece | |
pertenece [] x = False | |
pertenece (x:xs) num = (num==x) || pertenece xs num | |
--Ejercicio 3: interseccion |
This file contains 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
--Ejercicio 2: La historia sin fin | |
infinitosUnos = [1]++infinitosUnos | |
--Ejercicio 4: ¡Terminala! Parte 2 | |
sumatoria :: Num a => [a] -> a | |
sumatoria [] = 0 | |
sumatoria lista = head lista + sumatoria (tail lista) | |
--Ejercicio 5: El caso base | |
longitud [] = 0 |
This file contains 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
--Ejercicio 1: sumarSegun | |
sumarSegun :: (a->Int)->[a]->Int | |
sumarSegun fun = ((sum).(map fun)) | |
--Ejercicio 2: alguno | |
alguno :: (a -> Bool)-> [a] -> Bool | |
alguno cond list = filter cond list /= [] | |
--Ejercicio 3: esCapicua | |
esCapicua list = concat list == reverse (concat list) |
This file contains 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
--Ejercicio 4: algunosTuits | |
algunosTuits :: [a] -> [a] | |
algunosTuits = take 3 | |
--Ejercicio 7: El tipo de map | |
nuestroMap :: (b->a)->[b] -> [a] | |
--Ejercicio 8: Textos | |
textos :: [(String, String)] -> [String] | |
textos = map snd |
This file contains 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
--Ejercicio 1: Guardas: Básico | |
minimoEntre x y | x <= y = x | |
| y <= x = y | |
--Ejercicio 2: Otherwise | |
cantidadDePochoclosParaMinutosDeCine minutos | minutos < 40 = 2 | |
| minutos > 200 = 10 | |
| otherwise = ceiling (minutos / 20) | |
--Ejercicio 3: Orden de las Condiciones |
This file contains 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
--Ejercicio 1: esMultiploDe | |
esMultiploDe y =(==0).(rem) y | |
--Ejercicio 2: esBisiesto | |
esBisiesto :: Int -> Bool | |
esBisiesto x = (((esMultiploDe x 400)||).(esMultiploDe x 4 &&).(not.esMultiploDe x))100 | |
--Ejercicio 3: dobleDelLargo | |
dobleDelLargo = (*2).length |
This file contains 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
--Ejercicio 4: Aplicación Parcial, Parte 2 | |
dobleDelSiguiente = (*2).(+1) | |
--Ejercicio 5: Un saludo superior, Parte 1 | |
saludar nombre = "Hola " ++ nombre | |
--Ejercicio 6: Un saludo superior, parte 2 | |
saludar pref nombre = "Hola " ++ pref ++ " " ++ nombre | |
--Ejercicio 7: Un saludo superior, Parte 3 |
This file contains 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
--Ejercicio 1: mitad | |
mitad :: Float -> Float | |
mitad numero = numero / 2 | |
--Ejercicio 2: esParO | |
esParO :: Int -> Bool -> Bool | |
esParO numero condicion = even numero || condicion | |
--Ejercicio 3: sumarDos | |
sumarDos :: Num a => a-> a |
This file contains 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
--Ejercicio 4: Un poco más de inferencia | |
tipoDeXEnEsAdulta = "numero" | |
tipoDeRetornoEnEsAdulta = "booleano" | |
tipoDeXEnEsVacio = "string" | |
tipoDeRetornoEnEsVacio = "booleano" | |
--Ejercicio 6: Inferencia y composición, revisada | |
largoEsPar :: String -> Bool | |
largoEsPar = even.length |
This file contains 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
--Ejercicio 1: siguiente | |
siguiente x = x+1 | |
--Ejercicio 2: mitad | |
mitad x = x/2 | |
--Ejercicio 3: inversa | |
inversa x = (1/x) | |
--Ejercicio 4: esNumeroPositivo |
NewerOlder