/
ejercicios.hs
58 lines (39 loc) · 1.36 KB
/
ejercicios.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
siguiente :: Integer -> Integer
siguiente nro = nro + 1
doble :: Integer -> Integer
doble nro = nro * 2
calcular :: Integer -> Integer
calcular nro | even nro = siguiente nro
| otherwise = doble nro
calcular' :: (Integer, Integer) -> (Integer, Integer)
calcular' (nro, otroNum) = (primeroPar nro, segundoImpar otroNum)
primeroPar :: Integer -> Integer
primeroPar nro | even nro = doble nro
| otherwise = nro
segundoImpar :: Integer -> Integer
segundoImpar nro | odd nro = siguiente nro
| otherwise = nro
and' :: Bool -> Bool -> Bool
and' valor otroValor | valor = otroValor
| otherwise = False
and'' :: Bool -> Bool -> Bool
and'' True otroValor = otroValor
and'' _ _ = False
or' :: Bool -> Bool -> Bool
or' False False = False
or' _ _ = True
or'' :: Bool -> Bool -> Bool
or'' unValor otroValor | unValor = True
| otherwise = otroValor
or''' :: Bool -> Bool -> Bool
or''' False otroValor = otroValor
or''' _ _ = True
type Nota = Integer
type Alumno = (String, Nota, Nota, Nota)
notaMaxima :: Alumno -> Nota
notaMaxima (_, nota, nota2, nota3) = nota `max` (nota2 `max` nota3)
notaMaxima' :: Alumno -> Nota
notaMaxima' (_, nota, nota2, nota3) = max nota (max nota2 nota3)
cuadruple nro = doble (doble nro)
esMayorA :: Integer -> Bool
esMayorA nro = doble (siguiente (nro+2) ) > 10