comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: basic questions on using Ada arrays
Date: Fri, 08 Oct 2010 16:47:04 +0200
Date: 2010-10-08T16:47:04+02:00	[thread overview]
Message-ID: <871v80g2s7.fsf@hugsarin.sparre-andersen.dk> (raw)
In-Reply-To: i8ln5h$o0p$1@munin.nbi.dk

Randy Brukardt wrote;

> If you're using an Ada 2005, [...]

> function Apply(Func: access function(F: Float) return Float; Arr: 
> Float_Array) return Float_Array is
>
>>      Result: Float_Array(Arr'Range);
>>   begin
>>      for I in Result'Range loop
>>         Result(I) := Func(Arr(I));
>>      end loop;
>>      return Result;
>>   end Apply;

Wouldn't this implementation of the function be more elegant?

   function Apply (Func : access function (F : Float) return Float;
                   Arr  : in     Float_Array) return Float_Array is
   begin
      return Result : Float_Array (Arr'Range) do
         Result (I) := Func (Arr (I));
      end return;
   end Apply;

Greetings,

Jacob
-- 
Adlai Stevenson said it all when, at an event during the
1956 Presidential campaign, a woman shouted, "You have the
vote of every thinking person!" Stevenson shouted back,
"That's not enough, madam, we need a majority!"



  reply	other threads:[~2010-10-08 14:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-06 15:43 basic questions on using Ada arrays Nasser M. Abbasi
2010-10-06 16:17 ` Pascal Obry
2010-10-06 16:22 ` Jacob Sparre Andersen
2010-10-07  1:55   ` Keith Thompson
2010-10-08  0:04     ` Randy Brukardt
2010-10-08 14:47       ` Jacob Sparre Andersen [this message]
2010-10-09  6:35         ` Randy Brukardt
2010-10-26  2:20           ` Yannick Duchêne (Hibou57)
2010-10-06 17:03 ` Jeffrey Carter
2010-10-06 19:54 ` Simon Wright
2010-10-08  8:02 ` Alex Mentis
replies disabled

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