comp.lang.ada
 help / color / mirror / Atom feed
From: David Rasmussen <pinkfloydhomer@yahoo.com>
Subject: Re: Subtypes with Combined Ranges
Date: Thu, 18 Jul 2002 16:48:01 +0200
Date: 2002-07-18T16:48:01+02:00	[thread overview]
Message-ID: <3D36D521.6010708@yahoo.com> (raw)
In-Reply-To: 3D36C643.6020703@nbi.dk

Jacob Sparre Andersen wrote:
> David Rasmussen wrote:
> 
>> An Ada-excercise reads as follows:
>>
>> 6.1 Write a program to count the number of occurrences of each letter 
>> of the alphabet typed as input at the keyboard. Using a subtype of 
>> Character as the index subtype of an array is a sensible way to do this.
>>
>> My first thought was to do this:
>> subtype Alphabetical is Character range 'A'..'Z' | 'a'..'z';
> 
> 
> I think your problem is that you misunderstand the exercise. "The 
> alphabet" is just 'a' to 'z' and case insensitive. But since the 
> alphabet actually is 'a' to '�', and not just 'a' to 'z', the advise in 
> the exercise is inapropriate for other languages than English and Latin.
> 
> I would assume that the alphabet considered by the user is a subset of 
> the type Character, but include all elements of type Character 
> (converted to lower case) in the histogram, and not worry about which 
> elements to show until printing out the histogram.
> 
> Jacob

That is of course one way to do it. But I understood the word "subtype" 
in the excercise, in the Ada sense of the word. So I wanted to actually 
make a subtype, and then declare an array with this type as index type. 
I can do that with the lowercase letters, of course, as long as we're 
talking about English or Latin.

/David




      reply	other threads:[~2002-07-18 14:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-18 13:05 Subtypes with Combined Ranges David Rasmussen
2002-07-18 13:15 ` Lutz Donnerhacke
2002-07-18 13:44 ` Jacob Sparre Andersen
2002-07-18 14:48   ` David Rasmussen [this message]
replies disabled

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