comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <jacob@jacob-sparre.dk>
Subject: Re: basic question on adding 2 arrays
Date: Sun, 13 Jul 2014 18:25:12 +0200
Date: 2014-07-13T18:25:12+02:00	[thread overview]
Message-ID: <871ttp2plj.fsf@adaheads.sparre-andersen.dk> (raw)
In-Reply-To: 76d7dbf2-e6b8-4304-b90a-c29a5d129156@googlegroups.com

AdaMagica wrote:
> On Sunday, July 13, 2014 8:33:57 AM UTC+2, Jeffrey Carter wrote:

>> Next (Next'First + 1 .. Next'Last - 1) :=
>>     Next (Next'First .. Next'Last - 2) +
>>     Next (Next'First + 2 .. Next'Last);
>
> OK, one can do this, but is it better than Nasser's?
>
>>    for i in 2..next'length-1 loop
>>       next(i):= now(i-1)+now(i+1);
>>    end loop;

I would say that it depends on how the model is formulated, but without
that knowledge Nasser's version looks easier to understand.

Nasser's version also has the benefit of being safe in case of
by-reference passing of arrays.

Greetings,

Jacob
-- 
PNG: Pretty Nice Graphics

  reply	other threads:[~2014-07-13 16:25 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
2014-07-13 10:10     ` AdaMagica
2014-07-13 16:25       ` Jacob Sparre Andersen [this message]
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