From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,223570f8a5a85f0a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada Subject: Re: unbound array? From: Jim Rogers References: <41046a70@dnews.tpgi.com.au> Organization: Your Company Message-ID: User-Agent: Xnews/5.04.25 Date: Mon, 26 Jul 2004 03:10:42 GMT NNTP-Posting-Host: 12.73.182.142 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1090811442 12.73.182.142 (Mon, 26 Jul 2004 03:10:42 GMT) NNTP-Posting-Date: Mon, 26 Jul 2004 03:10:42 GMT Xref: g2news1.google.com comp.lang.ada:2386 Date: 2004-07-26T03:10:42+00:00 List-Id: "John Clarke" wrote in news:41046a70@dnews.tpgi.com.au: > Hello! > > I was hoping someone could shed some light. I am writing an ADA > program that reads a file and counts the number of words in the text > file and stores the word length, of each word encountered, in an > array. So for instance i have defined: > > size : integer := 100; > type length_type is array (1..size) of integer; > word_length : length_type; > > Now, if the text file is: "A rat was here." > > Hence, word_length(1) = 1, word_length(2) = 3, word_length(4) = 4 > etc... > > The problem I am facing is that I don't know how many words I will > encounter in the text file. I do not want to constrain size to 100 as > I have above. I know I can use unconstrained array type, but this also > doesn't solve the problem as an unconstrained array requires a > predefined size assigned prior to assigning values to it. > > I know that size will never be greater than the number of characters > in the text file. But it would be a little ridiculous assigning "size" > = "number of characters in text file". > > How can this problem be solved? Any help would be great. > Does the result have to be stored in an array? Can it be stored in a list instead? Jim Rogers