Si se están preguntándo...qué es Ada? Bueno...según Wikipedia...
Ada es un lenguaje de programación de alto nivel, estructurado, de tipeo estático, imperativo, de amplio espectro y orientado a objetos, extendido de Pascal y otros lenguajes.
Así que...sí...se ve bastante parecido a Pascal...pero mucho más estricto...y complejo...
Como siempre con mi "Mi primer post en..." construí un generador de lista Fibonacci...algo simple para comenzar a re-aprender el lenguaje...así que ahí les va...
| fibonacci.adb |
|---|
with Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
procedure Fibonacci is
package IO renames Ada.Text_IO;
package Number_IO is new Ada.Text_IO.Integer_IO (Integer);
num : Integer;
function Fib(num:Integer;a:Integer;b:Integer) return Unbounded_String is
result : Unbounded_String;
begin
if a > 0 and num > 1 then
result := result & Integer'Image(a+b) & " " & Fib(num-1,a+b,a);
elsif a = 0 then
result := Integer'Image(a) & " " & Integer'Image(b) & " " &
Integer'Image(a+b) & " " & Fib(num-1,a+b,b);
end if;
return result;
end Fib;
begin
IO.Put("Enter a number: ");
Number_IO.Get(num);
IO.Put(To_String(Fib(num,0,1)));
end Fibonacci;
|
Y aquí están las imágenes...
Bueno...eso fué relativamente sencillo...pero por supuesto, tuve que investigar un poco...así que el verdadero reto va a llegar cuando tenga que hacer mi aplicación de Números LED... -:P
Saludos,
Blag.
Development Culture.


No comments:
Post a Comment