Haskell
Haskell
Haskell
U N CURSO SOBRE
F UNCIONAL
P ROGRAMACI ON
hola
Blas Carlos Ruiz Jimenez,
Francisco Gutierrez
Lopez
y
Jose Enrique Gallardo Ruiz
Profesores del Departamento de Lenguajes y
Ciencias de la Computacion
Edita:
Imprime:
ISBN: ...
Deposito Legal: ...
Composicion: Realizada por los autores en LATEX2.
INDICE GENERAL
Indice
de figuras
XIII
Prologo
XVII
Convenios
XXIII
1. Programacion funcional
1.1. Funciones . . . . . . . . . . . . . . . . . . . . .
1.2. Sesiones y declaraciones . . . . . . . . . . . . . .
1.3. Reduccion de expresiones . . . . . . . . . . . . .
1.3.1. Ordenes
de reduccion aplicativo y normal
1.3.2. Evaluacion perezosa . . . . . . . . . . .
1.4. Sobre H ASKELL . . . . . . . . . . . . . . . . . .
2. Introduccion a H ASKELL
2.1. El lenguaje H ASKELL . . . . . . . . . .
2.2. Tipos simples predefinidos . . . . . . .
2.2.1. El tipo Bool . . . . . . . . . .
2.2.2. El tipo Int . . . . . . . . . . .
2.2.3. El tipo Integer . . . . . . . . .
2.2.4. El tipo Float . . . . . . . . . .
2.2.5. El tipo Double . . . . . . . . .
2.2.6. El tipo Char . . . . . . . . . .
2.2.7. Operadores de igualdad y orden
2.3. Constructores de tipos predefinidos . . .
2.3.1. Tuplas . . . . . . . . . . . . .
2.3.2. Listas . . . . . . . . . . . . . .
2.3.3. El constructor de tipo () . . .
2.4. Comentarios . . . . . . . . . . . . . . .
2.5. Operadores . . . . . . . . . . . . . . . .
2.5.1. Operadores frente a funciones .
2.6. Comparacion de patrones . . . . . . . .
2.6.1. Patrones constantes . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
4
6
9
9
11
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13
13
15
15
16
16
17
18
18
19
20
20
21
22
24
24
27
28
29
Indice general
VI
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
32
33
34
35
36
36
37
38
38
39
40
41
42
43
45
46
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
49
49
51
54
56
58
60
62
65
67
69
70
4. Definicion de tipos
4.1. Sinonimos de tipo . . . . . . . . . . . . . . . .
4.2. Definicion de tipos de datos . . . . . . . . . . .
4.2.1. Tipos enumerados . . . . . . . . . . .
4.2.2. Uniones . . . . . . . . . . . . . . . . .
4.2.3. Productos . . . . . . . . . . . . . . . .
4.2.4. Tipos recursivos . . . . . . . . . . . .
4.2.5. Tipos parametrizados (o polimorficos) .
4.2.6. Definiciones newtype . . . . . . . . .
4.3. Propiedades de funciones . . . . . . . . . . . .
4.3.1. La propiedad universal de foldNat . .
4.4. Sobrecarga y polimorfismo restringido . . . . .
4.4.1. Un ejemplo de sobrecarga . . . . . . .
4.5. Ejercicios . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
71
. 71
. 72
. 72
. 73
. 74
. 78
. 87
. 89
. 90
. 97
. 99
. 101
. 103
2.7.
2.8.
2.9.
2.10.
2.11.
2.12.
2.13.
2.14.
2.15.
Ambitos
y modulos . . . . . . . . . . . . .
Ejercicios . . . . . . . . . . . . . . . . . .
c ITES-Paraninfo
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Indice general
VII
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
105
105
105
109
111
112
115
115
118
118
119
122
123
125
126
128
129
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
131
131
132
134
136
137
140
141
142
144
147
148
148
151
153
154
155
156
158
159
159
160
161
162
164
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
c ITES-Paraninfo
Indice general
VIII
7. Entrada y salida
7.1. Operaciones de entrada y salida . . . . . . . . . .
7.1.1. El problema de la entrada y salida . . . .
7.1.2. El tipo IO . . . . . . . . . . . . . . . .
7.1.3. Excepciones . . . . . . . . . . . . . . .
7.2. Un formateador de textos . . . . . . . . . . . . .
7.2.1. Una implementacion ineficiente . . . . .
7.2.2. Una implementacion eficiente . . . . . .
7.2.3. Utilidades para el manejo de documentos
7.2.4. Una clase de tipos documentables . . . .
7.2.5. Ejemplos . . . . . . . . . . . . . . . . .
II
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Programacion avanzada
169
169
169
170
172
174
175
177
179
179
180
183
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
185
185
185
186
189
189
190
191
193
195
196
196
198
199
202
203
207
9.1. Arboles
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.1.1. Funciones de orden superior sobre a rboles . . . . . . .
9.2. Arboles
binarios . . . . . . . . . . . . . . . . . . . . . . . . . .
9.2.1. Arboles
binarios de busqueda . . . . . . . . . . . . . .
9.2.2. Funciones de orden superior para a rboles binarios . . .
9.2.3. Induccion para a rboles binarios . . . . . . . . . . . . .
9.3. Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9.3.1. Una implementacion ineficiente . . . . . . . . . . . . .
9.3.2. Una implementacion eficiente . . . . . . . . . . . . . .
9.4. Grafos y busqueda en grafos . . . . . . . . . . . . . . . . . . . .
9.4.1. Busqueda en anchura y en profundidad . . . . . . . . .
9.4.2. Los grafos como instancias de una clase uniparametrica
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
211
211
213
215
215
219
220
222
222
224
226
227
229
c ITES-Paraninfo
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Indice general
9.5.
9.6.
IX
.
.
.
.
.
.
.
.
232
232
234
236
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
243
243
243
243
245
246
247
247
247
249
253
254
255
257
258
259
259
261
261
262
264
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
265
265
266
266
269
272
273
276
277
280
283
283
284
286
288
291
292
296
297
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
c ITES-Paraninfo
Indice general
III
Aplicaciones
303
12.4. Algebra
lineal numerica . . . . . . . . . . . . .
12.5. Series de potencias . . . . . . . . . . . . . . . .
12.6. Ejercicios . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
305
305
305
308
312
314
316
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
319
319
319
320
322
324
327
327
329
330
333
333
336
338
339
342
14. Analizadores
14.1. Analizadores y la clase Read . . . . .
14.1.1. Gramaticas y la notacion BNF
14.1.2. El tipo Read . . . . . . . . .
14.1.3. La clase Read . . . . . . . .
14.2. Analizadores monadicos . . . . . . . .
14.2.1. Secuenciacion . . . . . . . .
14.2.2. Alternancia . . . . . . . . . .
14.2.3. Filtros . . . . . . . . . . . .
14.2.4. Iteracion . . . . . . . . . . .
14.2.5. Eleccion parcial . . . . . . .
14.2.6. Un analizador para terminos .
14.3. Ejercicios . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
345
345
346
347
356
357
358
359
360
361
362
363
366
c ITES-Paraninfo
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Indice general
XI
15. Simulacion
15.1. Generacion de aleatorios por congruencias . . . . . . . . .
15.1.1. Programando secuencias pseudo-aleatorias . . . .
15.1.2. Algunos resultados teoricos . . . . . . . . . . . .
15.2. Simulacion en el juego del poquer . . . . . . . . . . . . . .
15.2.1. Generando un mazo de cartas . . . . . . . . . . .
15.2.2. Busqueda de ciertas jugadas: parejas, tros, etc. . .
15.2.3. Contando todas las jugadas . . . . . . . . . . . .
15.3. Obteniendo semillas y aleatorios a traves del sistema . . . .
15.3.1. Un modelo monadico para la simulacion . . . . .
15.4. El juego de la lotera primitiva . . . . . . . . . . . . . . . .
15.4.1. Realizando escrutinios . . . . . . . . . . . . . . .
15.4.2. Generacion de sorteos . . . . . . . . . . . . . . .
15.4.3. Estudio estadstico de ciertas combinaciones . . .
15.4.4. Descripcion monadica del juego de la primitiva . .
15.5. Simulacion monadica de juegos con dados . . . . . . . . .
15.5.1. Mezclando valores producidos por varias acciones
15.5.2. Plegando valores monadicos . . . . . . . . . . . .
15.5.3. Repeticion de varias tiradas con varios dados . . .
15.5.4. Contabilizando jugadas . . . . . . . . . . . . . .
IV
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Aspectos teoricos
369
369
370
373
374
374
375
376
379
380
383
383
384
385
387
388
389
389
391
392
395
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
397
397
405
405
410
414
417
417
418
420
425
425
426
426
427
430
432
434
437
439
441
443
c ITES-Paraninfo
XII
Indice general
17.4. Ordenes
de reduccion. Teorema de estandarizacion . . . . . . . . .
17.5. Lambda definibilidad . . . . . . . . . . . . . . . . . . . . . . . .
17.5.1. Operaciones logicas . . . . . . . . . . . . . . . . . . . .
17.5.2. Computabilidad . . . . . . . . . . . . . . . . . . . . . .
17.5.3. Puntos fijos y recursion . . . . . . . . . . . . . . . . . .
17.5.4. Listas en el C . . . . . . . . . . . . . . . . . . . . . . .
17.6. Los sistemas de tipos de Church y de Curry . . . . . . . . . . . . .
17.6.1. Propiedades del sistema Curry . . . . . . . . . . . . .
17.6.2. La correspondencia de Howard-Curry-de Bruijn . . . . .
17.7. Ejemplos practicos de inferencia de tipos . . . . . . . . . . . . . .
17.7.1. Caso de un u nico argumento . . . . . . . . . . . . . . . .
17.7.2. Caso de varios argumentos . . . . . . . . . . . . . . . . .
17.7.3. Caso en que aparecen otras variables predefinidas . . . .
17.8. Inferencia de tipos en presencia de recursion . . . . . . . . . . . .
17.9. Inferencia de tipos en presencia de patrones . . . . . . . . . . . .
17.10. Reglas elementales para inferencia de tipos . . . . . . . . . . . . .
17.11. El -calculo polimorfico . . . . . . . . . . . . . . . . . . . . . . .
17.11.1. Inferencia de tipos en presencia de polimorfismo . . . . .
17.11.2. Un teorema de parametricidad para funciones polimorficas
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
451
451
453
457
459
460
461
465
468
469
469
471
473
474
475
478
478
479
480
482
484
487
490
492
494
496
Bibliografa
499
Indice
alfabetico
503
c ITES-Paraninfo
INDICE DE FIGURAS
1.1.
1.2.
10
10
2.1.
2.2.
2.3.
26
44
44
3.1.
3.2.
3.3.
3.4.
Aplicaciones parciales . . . .
La funcion unaVez . . . . .
La funcion dosVeces . . . .
La composicion de funciones
.
.
.
.
52
61
62
63
4.1.
. . . . . . . . . . . . . . . . . . .
86
5.1.
5.2.
5.3.
6.1.
6.2.
6.3.
6.4.
6.5.
6.6.
6.7.
6.8.
La clase Enum . . . . . . . . . . . . . . .
head , tail , init y last . . . . . . . . . . . .
take, drop y (!!) . . . . . . . . . . . . . . .
Reduccion de foldr f z [x1 , . . . , xn1 , xn ]
Reduccion de foldr 1 f [x1 , . . . , xn1 , xn ] .
Reduccion de foldl f z [x1 , . . . , xn1 , xn ] .
Ordenacion por mezcla . . . . . . . . . . .
Ordenacion rapida . . . . . . . . . . . . . .
7.1.
7.2.
8.1.
8.2.
8.3.
8.4.
8.5.
8.6.
8.7.
La funcion incr . . . . . . . . . . . . . . . . . .
Red para la evaluacion de los enteros positivos . .
Red de procesos para sucesiones . . . . . . . . .
Red de procesos para la criba de Eratostenes . . .
Red para el triangulo de Pascal . . . . . . . . . .
Red de procesos para la lista de factoriales . . . .
Red para el computo de los numeros de Fibonacci
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
132
138
139
150
151
153
157
158
192
192
193
195
196
197
199
Indice de figuras
XIV
Arbol
para creaArray [0..7] . .
Un grafo . . . . . . . . . . . .
Otro grafo . . . . . . . . . . .
Arbol
de visitas en profundidad
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
211
216
217
225
227
227
228
228
231
235
238
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
266
273
273
274
274
275
276
277
277
278
278
279
287
289
289
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
321
323
325
326
331
332
334
334
335
337
Indice de figuras
13.11. Las torres de Hanoi . . . . . . . . . . . . . . . . .
13.12. El problema de las Torres de Hanoi con cuatro torres
13.13. El tablero del solitario . . . . . . . . . . . . . . . .
13.14. Un cuadrado magico . . . . . . . . . . . . . . . . .
13.15. El problema de los tres sombreros . . . . . . . . . .
13.16. Los cuatro caballos . . . . . . . . . . . . . . . . .
13.17. El problema de los trenes . . . . . . . . . . . . . .
13.18. Un polgono . . . . . . . . . . . . . . . . . . . . .
13.19. La va . . . . . . . . . . . . . . . . . . . . . . . .
XV
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
338
339
339
340
340
342
343
343
343
c ITES-Paraninfo