-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.hs
128 lines (109 loc) · 2.21 KB
/
menu.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
main = do
print("1 - Serie Fibonacci")
print("2 - Presentar numeros del 1 al 10")
print("3 - Factorial")
print("4 - Desaparece numeros")
print("5 - Palindromos")
print("6 - Menu de calculadora")
print("7 - Salir")
n <- getLine
casos (read n)
casos n = do
case n of
1 -> do
putStrLn("¿Que posicion deseas?")
p <- getLine
serie 0 1 1 (read p)
2 -> unoAdiez 1
3 -> factorial
4 -> desaparecer [1,2,3,4,5,6,7,8,9,10]
5 -> palindromo
6 -> calculadora
7 -> putStrLn("Adios :)")
-- 1 - 10
unoAdiez n = do
if n<= 10
then do
print n
unoAdiez (n+1)
else
main
-- Factorial
factorial = do
print("Ingresa el numero: ")
n <- getLine
print ((product [1..(read n)]))
main
-- Palindromo
palindromo = do
print("Ingresa los elementos: ")
p <- getLine
if p == reverse p
then do
print("Es palindromo")
else
print("No es palindromo")
main
-- Desaparecer numeros
desaparecer n = do
if length n >1
then do
print (n)
desaparecer (take ((length n)-1) n )
else
print(n)
main
-- calculadora
calculadora = do
print("1 - Suma")
print("2 - Resta")
print("3 - Multiplicar")
print("4 - Dividr")
print("5 Salir")
n <- getLine
menuCalc (read n)
menuCalc n = do
case n of
1 -> sumar
2 -> restar
3 -> multiplicar
4 -> dividir
5 -> main
sumar = do
putStrLn ("Ingresa numero 1")
a <- getLine
putStrLn ("Ingresa numero 2")
b <- getLine
putStrLn ("= "++show(read a + read b))
calculadora
restar = do
putStrLn ("Ingresa numero 1")
a <- getLine
putStrLn ("Ingresa numero 2")
b <- getLine
putStrLn ("= "++show(read a - read b))
calculadora
multiplicar = do
putStrLn ("Ingresa numero 1")
a <- getLine
putStrLn ("Ingresa numero 2")
b <- getLine
putStrLn ("= "++show(read a * read b))
calculadora
dividir = do
putStrLn ("Ingresa numero 1")
a <- getLine
putStrLn ("Ingresa numero 2")
b <- getLine
putStrLn ("= "++show(read a / read b))
calculadora
-- SERIE
serie a b c l = do
if l > c
then do
serie b (a+b) (c+1) l
else
do
print("La posicion es: ")
print(a)
main