From: Leandro Lucarella Date: Thu, 28 Jul 2005 05:39:52 +0000 (+0000) Subject: Ejercicios del capítulo 2. X-Git-Tag: svn_import X-Git-Url: https://git.llucax.com/z.facultad/75.31/ejercicios.git/commitdiff_plain Ejercicios del capítulo 2. --- diff --git a/2.1.oz b/2.1.oz new file mode 100644 index 0000000..ed39a78 --- /dev/null +++ b/2.1.oz @@ -0,0 +1,21 @@ +/**************************************************************************** +Ejercicio: 2.1 +Alumno: Leandro Lucarella +Fecha: mié jul 27 14:34:05 ART 2005 +****************************************************************************/ + +functor +import + Application + System +define + proc {P X} + if X>0 then {P X-1} end % La llamada es unbounded + {System.show X} + end + % Imprimimos algo de ejemplo + {P 5} + {Application.exit 0} +end + +% vim: set et sw=4 sts=4 filetype=oz : diff --git a/2.10.oz b/2.10.oz new file mode 100644 index 0000000..eac118e --- /dev/null +++ b/2.10.oz @@ -0,0 +1,28 @@ +/**************************************************************************** +Ejercicio: 2.10 +Alumno: Leandro Lucarella +Fecha: mié jul 27 15:59:18 ART 2005 +****************************************************************************/ + +functor +import + Application + System +define + + fun {SMerge Xs Ys} + case Xs#Ys + of nil#Ys then Ys + [] Xs#nil then Xs + [] (X|Xr)#(Y|Yr) then + if X=Value then X else Value end + end + end + {SpecialMax 3 Max3} % Algo así como un constructor de funciones + {SpecialMax 5 Max5} + {System.show [{Max3 4} {Max5 4}]} + {Application.exit 0} +end + +% vim: set et sw=4 sts=4 filetype=oz : diff --git a/2.9.oz b/2.9.oz new file mode 100644 index 0000000..99a22ed --- /dev/null +++ b/2.9.oz @@ -0,0 +1,27 @@ +/**************************************************************************** +Ejercicio: 2.9 +Alumno: Leandro Lucarella +Fecha: mié jul 27 15:45:41 ART 2005 +****************************************************************************/ + +functor +import + Application + System +define + fun {Sum1 N} + if N==0 then 0 else N+{Sum1 N-1} end + end + fun {Sum2 N S} + if N==0 then S else {Sum2 N-1 N+S} end + end + + %{System.show {Sum1 100000000}} No funciona, se agota la memoria + + {System.show {Sum2 100000000 0}} % Anda, supongo que porque lo puede + % convertir en un ciclo + + {Application.exit 0} +end + +% vim: set et sw=4 sts=4 filetype=oz :