comp.lang.ada
 help / color / mirror / Atom feed
From: Preben Randhol <randhol+news@pvv.org>
Subject: Re: Thanks guys..my project and my many problems
Date: Mon, 24 Feb 2003 15:12:08 +0000 (UTC)
Date: 2003-02-24T15:12:08+00:00	[thread overview]
Message-ID: <slrnb5kdg7.7lb.randhol+news@kiuk0152.chembio.ntnu.no> (raw)
In-Reply-To: 3E5A2381.21FD3F14@bton.ac.uk

Paul Gregory wrote:
> Thank-you Larry and Preban for your kind help.
                          e ;-)
>   type English is
>     (big, black, cat, dog, es, small, the, white);
> 
>   type French is (grand, noir, chat, chien, est, petit, le, blanc);
> 
>   English_to_French: constant array(English) of French:=
>     ( big                 => grand,
>       black          => noir,
>       cat               => chat,
>       dog => chien,
>       es     => est,
>       small             => petit,
>       the => le,
>       white        => blanc);
> 

Why do you use enumerates? Is it required? If you are supposed to be
able to add words and possibly store them too, why don't you rather make
something like:

   type Max_Word_Length : constant Natural := 80;

   type Word_Record is
      record
         english : String (1 .. Max_Word_Length);
         french  : String (1 .. Max_Word_Length);
      end record;

of course you have to build a linked list or an array and a way to
search for the correct word. 

Another way could be to use arrays (you don't have to deal with
the linked list problems) but have the design a bit more flexible so
you can add more languages if you want:

   type Dictionary is
      record
         word_id : Natural := 0;
         word    : String (1 .. Max_Word_Length);
      end record;

   type English_List is array (1 .. 1000) of Dictionary;
   type French_List is array (1 .. 1000) of Dictionary;

then when you add you generate a unique word_id /= 0 for each word and
you put this in the English list along with the English word and in the
French list with the french word. So that when you look up a word you
get the word_id and you use this to find the same word in the other
language. Of course you don't have to do this if you know that word
number 3 in the English list will correspond with word number 3 in the
French.

Please note I haven't checked my code so there might be errors in it.

Hope you can get further on your project with this.

-- 
Preben Randhol ---------------- http://www.pvv.org/~randhol/ --
"Violence is the last refuge of the incompetent", Isaac Asimov



  reply	other threads:[~2003-02-24 15:12 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-24 13:52 Thanks guys..my project and my many problems Paul Gregory
2003-02-24 15:12 ` Preben Randhol [this message]
2003-02-24 15:38 ` Hyman Rosen
2003-02-24 18:08   ` Preben Randhol
2003-02-25  2:01     ` Hyman Rosen
2003-02-25  9:46       ` Preben Randhol
2003-02-25 16:07         ` Hyman Rosen
2003-02-24 18:37   ` Simon Wright
2003-02-24 22:55     ` Jano
2003-02-25 17:36       ` Matthew Heaney
2003-02-25 21:56     ` Simon Wright
2003-02-25  8:45   ` Rodrigo García
2003-02-25 17:34   ` Matthew Heaney
2003-02-25 18:03     ` Hyman Rosen
2003-02-26  8:14       ` Preben Randhol
2003-02-25 17:31 ` Matthew Heaney
2003-02-25 19:57   ` chris.danx
2003-02-25 21:17     ` Chad R. Meiners
2003-03-05  9:22       ` chris.danx
2003-02-26 14:06   ` Paul Gregory
2003-02-26 18:09     ` tmoran
2003-02-27 17:12     ` Update - PLEASE SOMEBODY HELP!!!! Paul Gregory
     [not found]       ` <bot2j-ei3.ln1@beastie.ix.netcom.com>
2003-02-28 10:16         ` Georg Bauhaus
2003-02-28 10:53           ` Paul Gregory
2003-02-28 16:47             ` Simon Wright
replies disabled

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