comp.lang.ada
 help / color / mirror / Atom feed
* matrix
@ 2003-09-23 12:05 Daniel Sch�le
  2003-09-23 12:17 ` matrix Lutz Donnerhacke
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Sch�le @ 2003-09-23 12:05 UTC (permalink / raw)


Hi all

type matrix is array(integer range <>, integer range <>) of integer;
..
m: matrix(1..10, 1..5);
..
for i in m'first..m'last loop                -- 1 to 10
    for j in m(i)'first .. m(i)'last loop    -- doesnt work
        put(m(i, j)'image);
    end loop;
end loop;


what is the proper way to iterate through the matrix?

thanks for answears

--
Daniel





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: matrix
  2003-09-23 12:05 matrix Daniel Sch�le
@ 2003-09-23 12:17 ` Lutz Donnerhacke
  0 siblings, 0 replies; 2+ messages in thread
From: Lutz Donnerhacke @ 2003-09-23 12:17 UTC (permalink / raw)


* Daniel Sch�le wrote:
> what is the proper way to iterate through the matrix?

with Ada.Text_IO;
use Ada.Text_IO;

procedure t is
   type Matrix is array(Integer range <>, Integer range <>) of Integer;
   m: Matrix(1..10, 1..5) := (
     2 .. 5 => (3 .. 4 => 1, others => 0),
     others => (others => 0)
   );
begin
   for x in m'Range(1) loop
      for y in m'Range(2) loop
         Put(Integer'Image(m(x, y)));
      end loop;
      New_Line;
   end loop;
end t;
   



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-09-23 12:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-23 12:05 matrix Daniel Sch�le
2003-09-23 12:17 ` matrix Lutz Donnerhacke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox