comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: basic question on adding 2 arrays
Date: Sat, 12 Jul 2014 23:33:57 -0700
Date: 2014-07-12T23:33:57-07:00	[thread overview]
Message-ID: <lpt98m$3q5$1@dont-email.me> (raw)
In-Reply-To: <lpt0pj$jc0$1@speranza.aioe.org>

On 07/12/2014 09:09 PM, Nasser M. Abbasi wrote:
>
> This is what I tried. But after making special
> "+" to add the 2 slices of grid_type, by making
> new grid_type2 which is 2 elements smaller than
> grid_type, how does not tell Ada to move this
> grid_type2 into grid_type since they are of
> different type?  Do I need another loop for this?


type Base_Grid is array (Positive range <>) of Float;
subtype Grid_Type is Base_Grid (1 .. Npoints);

function "+" (Left : in Base_Grid; Right : in Base_Grid) return Base_Grid with
Pre => Left'Length = Right'Length;

Next (Next'First + 1 .. Next'Last - 1) :=
    Next (Next'First .. Next'Last - 2) +
    Next (Next'First + 2 .. Next'Last);

-- 
Jeff Carter
"I would never want to belong to any club that
would have someone like me for a member."
Annie Hall
41


  parent reply	other threads:[~2014-07-13  6:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13  3:34 basic question on adding 2 arrays Nasser M. Abbasi
2014-07-13  4:09 ` Nasser M. Abbasi
2014-07-13  4:35   ` Nasser M. Abbasi
2014-07-13  6:33   ` Jeffrey Carter [this message]
2014-07-13 10:10     ` AdaMagica
2014-07-13 16:25       ` Jacob Sparre Andersen
2014-07-13 21:53       ` Jeffrey Carter
replies disabled

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