comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Beginner's question (array parameters to functions)
Date: 1998/11/29
Date: 1998-11-29T00:00:00+00:00	[thread overview]
Message-ID: <m3ww4fxmnf.fsf@mheaney.ni.net> (raw)
In-Reply-To: Pine.BSF.4.05.9811281727020.10058-100000@shell5.ba.best.com

Brian Rogoff <bpr@shell5.ba.best.com> writes:

> On Sat, 28 Nov 1998, Matthew Heaney wrote:
> > greg <ref15@columbia.edu> writes:
> > ... array sorting question snipped ...
> > 
> > But there are two arrays no matter what: one is unsorted, and one is
> > sorted.  Having two arrays is a condition of the problem statement, and
> > has nothing to do with the language.
> 
> The problem statement said nothing about whether the sort modified the
> original array or not. Ada doesn't specify whether arrays are passed by 
> reference; if you want to do a sort in place and return the same array 
> then you'll use access types (pointers if you speak C) and work with 
> references to the array. I consider it an excellent feature of Ada that
> there is no extra syntax for this, unlike C. 

The problem was: "implement a sort routine as a function, that takes an
unsorted array as the parameter, and returns a sorted array as a
result."

Something like:

   function Sort (Items : Item_Array) return Item_Array;

This problem requires two arrays.

It may be that "the problem statement said nothing about whether the
sort modified the original array or not," but the implicit requirement
for a pair of arrays is derived from the explicit requirement that the
sort be implemented as a function.












  reply	other threads:[~1998-11-29  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-27  0:00 Beginner's question (array parameters to functions) greg
1998-11-28  0:00 ` Matthew Heaney
1998-11-28  0:00   ` Brian Rogoff
1998-11-29  0:00     ` Matthew Heaney [this message]
1998-11-29  0:00   ` Fergus Henderson
1998-11-29  0:00     ` Matthew Heaney
1998-12-02  0:00       ` Fergus Henderson
1998-11-28  0:00 ` Tom Moran
replies disabled

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