comp.lang.ada
 help / color / mirror / Atom feed
* Qu: 3D unconstrained arrays
@ 1995-02-08 22:57 Randy Binnie
  1995-02-09  1:40 ` Kent Mitchell
  1995-02-10  4:20 ` Michael Feldman
  0 siblings, 2 replies; 3+ messages in thread
From: Randy Binnie @ 1995-02-08 22:57 UTC (permalink / raw)



Hi,  Assuming this news group allows non political postings, I have an
Ada implementation question???


How can one create a 3 dimensional unconstrained array  made up of a one
dimensional  unconstrained array  and a two dimensional unconstrained array.
Ideally I would like to do the following, but it is not allowed because the
type  ARRAY_2D_TYPE  is unconstrained.

  type ARRAY_2D_TYPE  is array ( range <>, range <>)  of DATA_TYPE;
  type ARRAY_3D_TYPE  is array ( range <>)  of  ARRAY_2D_TYPE;
  

I could do it by creating access pointers to the 2-D array type such as

  type ARRAY_2D_TYPE  is array ( range <>, range <>)  of DATA_TYPE;
  type ACCESS_2D_TYPE is access  ARRAY_2D_TYPE;
  type ARRAY_3D_TYPE  is array ( range <>)  of  ACCESS_2D_TYPE;


but I would prefer a cleaner solution using a single monolithic 3 dimensional 
data structure.  So my question is can it be done, if so a brief explaination 
would be appreciated.  This is for an Ada '83 compiler.


Thanks for any feedback you may have.


--

-----------------------------------------------------
Randy Binnie            FlightSafety International
                        Broken Arrow, Oklahoma 74012
randyb@ssd.fsi.com      918-251-0500 ext.  464
-----------------------------------------------------




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

* Re: Qu: 3D unconstrained arrays
  1995-02-08 22:57 Qu: 3D unconstrained arrays Randy Binnie
@ 1995-02-09  1:40 ` Kent Mitchell
  1995-02-10  4:20 ` Michael Feldman
  1 sibling, 0 replies; 3+ messages in thread
From: Kent Mitchell @ 1995-02-09  1:40 UTC (permalink / raw)


Randy Binnie (randyb@ssd.fsi.com) wrote:

: Hi,  Assuming this news group allows non political postings, I have an
: Ada implementation question???
We always accept non-political postings.  In fact we prefer them but some
times ....

: How can one create a 3 dimensional unconstrained array  made up of a one
: dimensional  unconstrained array  and a two dimensional unconstrained array.
: Ideally I would like to do the following, but it is not allowed because the
: type  ARRAY_2D_TYPE  is unconstrained.

:   type ARRAY_2D_TYPE  is array ( range <>, range <>)  of DATA_TYPE;
:   type ARRAY_3D_TYPE  is array ( range <>)  of  ARRAY_2D_TYPE;
This exact structure is not possible so you can't create what you describe
above (a two dimensional unconstrained array containing a one dimensional
unconstrained array).  However, see below to create what you want as you
cleaner solution.

: but I would prefer a cleaner solution using a single monolithic 3 dimensional 
: data structure.  So my question is can it be done, if so a brief explaination 
: would be appreciated.  This is for an Ada '83 compiler.

A monolithic 3d array is declared as:

    type Array_3D_Type is
      array (Positive range <>, Positive range <>, Positive range <>)
      of Data_Type;

Note: I had to add a type for the range <>.  I picked positive but any
discrete type will do.
--
Kent Mitchell                   | One possible reason that things aren't
Technical Consultant            | going according to plan is .....
Rational Software Corporation   | that there never *was* a plan!



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

* Re: Qu: 3D unconstrained arrays
  1995-02-08 22:57 Qu: 3D unconstrained arrays Randy Binnie
  1995-02-09  1:40 ` Kent Mitchell
@ 1995-02-10  4:20 ` Michael Feldman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Feldman @ 1995-02-10  4:20 UTC (permalink / raw)


In article <RANDYB.95Feb8165716@oh58d-pdssc.ssd.fsi.com>,
Randy Binnie <randyb@ssd.fsi.com> wrote:
>
>Hi,  Assuming this news group allows non political postings, I have an
>Ada implementation question???

Yeah, technical questions are allowed, though sometimes it's hard to tell!
>
>How can one create a 3 dimensional unconstrained array  made up of a one
>dimensional  unconstrained array  and a two dimensional unconstrained array.

It's not clear to me why a regular ol' 3-dimensional array type is not OK.
Why not do it the simple way, like

  TYPE 3DArray IS ARRAY (Foo RANGE <>, Bar RANGE <>, Glurk RANGE <>)
     OF DataType;

Perhaps you didn't describe the problem fully. 

Mike Feldman
------------------------------------------------------------------------
Michael B. Feldman -  chair, SIGAda Education Working Group
Professor, Dept. of Electrical Engineering and Computer Science
The George Washington University -  Washington, DC 20052 USA
202-994-5919 (voice) - 202-994-0227 (fax) - mfeldman@seas.gwu.edu (Internet)
------------------------------------------------------------------------
One, two, three ways an underdog: Ada fan, Mac fan, Old Liberal Democrat
------------------------------------------------------------------------
         Ada on the World-Wide Web: http://lglwww.epfl.ch/Ada/
------------------------------------------------------------------------



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

end of thread, other threads:[~1995-02-10  4:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-02-08 22:57 Qu: 3D unconstrained arrays Randy Binnie
1995-02-09  1:40 ` Kent Mitchell
1995-02-10  4:20 ` Michael Feldman

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