From 6a5e85cd139e0d2bc219a3600a4d6f06bf77cc6d Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 28 Jul 2005 05:39:52 +0000 Subject: [PATCH] =?utf8?q?Ejercicios=20del=20cap=C3=ADtulo=202.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- 2.1.oz | 21 +++++++++++++++++++++ 2.10.oz | 28 ++++++++++++++++++++++++++++ 2.11.oz | 28 ++++++++++++++++++++++++++++ 2.2.oz | 24 ++++++++++++++++++++++++ 2.3.oz | 27 +++++++++++++++++++++++++++ 2.4.oz | 23 +++++++++++++++++++++++ 2.5.oz | 33 +++++++++++++++++++++++++++++++++ 2.6.oz | 30 ++++++++++++++++++++++++++++++ 2.7.oz | 24 ++++++++++++++++++++++++ 2.9.oz | 27 +++++++++++++++++++++++++++ 10 files changed, 265 insertions(+) create mode 100644 2.1.oz create mode 100644 2.10.oz create mode 100644 2.11.oz create mode 100644 2.2.oz create mode 100644 2.3.oz create mode 100644 2.4.oz create mode 100644 2.5.oz create mode 100644 2.6.oz create mode 100644 2.7.oz create mode 100644 2.9.oz 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 : -- 2.43.0