Vectores
Definiciones restringidas
type t1 is array (1..10) of boolean; //tipo t1 es un vector de 10 posiciones de booleanos;
type t2 is array (dia) of t1; //el vector t2 es un vector de las posiciones de lunes a sabado que componen valores contenidos en el t1;
type t3 is array (lunes..jueves, -10..14) of t1; //es como trabajar con una matriz;
x:t1; y:t2; z:t3; // esto es la declaración de las variables después del tipo;
x(i+j)
y (martes)
y(martes)(i+j)
z(martes, i+j)
x(5..8)
y(martes..viernes)
Definiciones no restringidas
type matriz is array (positive range <>, positive range <>) of real;
function "+" (a,b:matriz) return matriz is begin....¿?¿
Atributos relacionados con los índices
function "+" (a, b:matriz) return matriz is suma: matriz (a'range(1), a'range(2));
begin
for i in a'range(1) loop
for j in a'range(2) loop
suma (i, j) := ...¿?¿?
Constantes de tipos vectoriales
m1:=((1..3=>1.0), (1=>2.0, 2=>3.0,3=>4.0));
m2:=mat23' (1=>(1=>1.0, others=>0.0), 2=>(2=>1.0, others=>0.0));
¡Atención 'others' exige límites conocidos!
Tipo no restringido predefinido: string
type string is array (positiverange <>) of character;
x0: string(1..8);
subtype s1 is string (2..8);
subtype linea is string (1..80);
x1:s1;
l: linea;
1(3..10):=x0;
1(2..4=:=x0 (4..6);
1(1..8):=x0 (1..4) & "A" & x1 (2..4);
Las constantes de tipo cadena se escriben entre comillas.
¡Ojo! ¡x0 es una cadena de caracteres de longitud exactamente 8!
Tipos compuestos:Registros
Registros
type nombre_mes is (ene, feb, marm abr, may, jun, jul, ago, sep, oct, nov, dic);
type fecha is record...¿?¿?
Un registro no puede tener campos de tipo vector no restringido
Hay otras formas de definir tipos registro, por ejemplo, incluyendo partes variantes (ver bibliografía)
Lo siento, hoy llegue muy tarde y no pille los apuntes muy bien. Pero ayer subí el pdf con toda la información que tengo de Ada en la documentación de la segunda evaluación. Así que ya sabes, estudia mucho ;)
0 comentarios:
Publicar un comentario