comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: unconstrained array type problems
Date: Wed, 21 Jul 2004 18:30:40 GMT
Date: 2004-07-21T18:30:40+00:00	[thread overview]
Message-ID: <kDyLc.157648$XM6.36144@attbi_s53> (raw)
In-Reply-To: 40fea9b7@dnews.tpgi.com.au

>open (file)
>
>read in dimensions of array1
>create the array1
>fill the array1
>
>read in dimensions of array2
>create the array2
>fill the array2
>
>close (file)
>
>allow the arrays to interact with one another
>---
>
>I cannot see a way around this.


Repeating and expanding on Marius Amado Alves message:
> > How can i make them visible to one another? This is so easy to do in
> > c++/java.
>
> This is extremely easy in Ada with the proper design, namely with these
> two entities:
>
>     type Matrix is array (Positive range <>, Positive range <>) of Real;
    function Read_Matrix(File : File_Type) return Matrix is
      Row_Count, Column_Count : Positive;
    begin
      Get (File, Row_Count);
      Get (File, Column_Count);
      declare
        Result: Matrix_Type (1 .. Row_Count, 1 .. Column_Count);
      begin
        -- read in matrix data
        return Result;
      end;
    end Read_Matrix;
>
> Then read all the matrices you want in the same place:
>
    procedure Do_Matrices is
>     Matrix_1 : Matrix := Read_Matrix(File);
>     Matrix_2 : Matrix := Read_Matrix(File);
      Product  : Matrix(Matrix_1'range(1), Matrix_2'range(2)); -- for example
    begin
      -- do stuff with Matrix_1 and Matrix_2
    end Do_Matrices;



  reply	other threads:[~2004-07-21 18:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-21 15:04 unconstrained array type problems zork
2004-07-21 15:09 ` Ludovic Brenta
2004-07-21 15:33   ` zork
2004-07-21 15:54     ` Marius Amado Alves
2004-07-21 16:24       ` Ludovic Brenta
2004-07-21 17:33         ` Georg Bauhaus
2004-07-21 17:35         ` zork
2004-07-21 18:30           ` tmoran [this message]
2004-07-21 23:11             ` zork
2004-07-22  7:57     ` Martin Krischik
replies disabled

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