comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent <daemon2@internet.lu>
Subject: Re: Problem with generic package
Date: Tue, 15 Apr 2014 14:12:07 -0700 (PDT)
Date: 2014-04-15T14:12:07-07:00	[thread overview]
Message-ID: <1807366a-55d8-4d47-953c-d857f69a3306@googlegroups.com> (raw)
In-Reply-To: <ly4n1ul3zt.fsf@pushface.org>


> so delete the first line and replace Exchange by Swap_Generic in the...

I got that by myself so at least some progress :)

The whole problem comes from the fact that swap_generic and sort_generic where given in the book, the search_generic was left as exercise which I was able to solve.

Just trying to get those 3 things in one package disturbed me. At least I probably won't forget it. 

MacOS doesn't care about case even if it is unix based.

Tried to use my array_generics in some test program. 
error: invalid prefix in selected component "Array_Generics"

the with'ing and prefix'ing is also proposed by gps. perhaps again the same problem as before? not understanding what I am doing? 

Thanks


with Ada.Text_IO;
with Ada.Integer_Text_IO;
with Ada.Float_Text_IO;
with Array_Generics;

procedure Test_Search_Array_Generic is

   subtype Index is Integer range 1 .. 10;

   type Float_Vector is array (Index range <>) of Float;

   V1 : Float_Vector (1 .. 10);

 ==>  function Search_Float is new Array_Generics.Search_Generic
     (List_Type => Float_Vector, Index_Type => Index, Element_Type => Float); <== error

   procedure Display_Float_Vector (V : Float_Vector) is

      Target: Float;

   begin -- Display_Float_Vector

      Ada.Text_IO.Put (Item => "Please enter the value to search for: ");
      Ada.Float_Text_IO.Get (Item => Target);
      Ada.Integer_Text_IO.Put (Item => Search_Float (List => V, Target => Target),Width => 1);
      Ada.Text_IO.New_Line;

   exception
      when Array_Generics.Item_Not_Found =>
         Ada.Text_IO.Put (Item => "Target not found!");

   end Display_Float_Vector;

begin

   V1 := (0.7, 1.5, 6.9, -3.2, 0.0, 5.1, 2.0, 7.3, 2.2, -5.9);

   Display_Float_Vector (V => V1);

end Test_Search_Array_Generic;



  reply	other threads:[~2014-04-15 21:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-15 18:26 Problem with generic package Laurent
2014-04-15 19:36 ` Adam Beneschan
2014-04-15 19:44 ` Adam Beneschan
2014-04-15 20:12   ` Laurent
2014-04-15 20:37     ` Adam Beneschan
2014-04-15 20:43     ` Eryndlia Mavourneen
2014-04-15 20:47       ` Eryndlia Mavourneen
2014-04-15 21:28     ` Georg Bauhaus
2014-04-15 20:41 ` Simon Wright
2014-04-15 21:12   ` Laurent [this message]
2014-04-15 21:27     ` Adam Beneschan
2014-04-15 21:58       ` Laurent
2014-04-15 22:03         ` Adam Beneschan
2014-04-16  6:03         ` Georg Bauhaus
2014-04-16 20:37           ` Laurent
2014-04-16 21:13             ` Mike H
2014-04-16 22:31               ` Randy Brukardt
2014-04-16 23:06               ` Jeffrey Carter
2014-04-15 22:14     ` Simon Wright
2014-04-16 18:49       ` Laurent
replies disabled

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