comp.lang.ada
 help / color / mirror / Atom feed
From: "KE" <koray.erkan@yahoo.com>
Subject: Re: Char type verification
Date: 15 Nov 2006 15:55:24 -0800
Date: 2006-11-15T15:55:24-08:00	[thread overview]
Message-ID: <1163634924.601043.69250@b28g2000cwb.googlegroups.com> (raw)
In-Reply-To: <1163633783.126843.241410@i42g2000cwa.googlegroups.com>

Thanks Adam.

First of all, I'm grateful that you've gone to all that length to
explain to me that this is not the most efficient way to do this, etc.
etc. I am familiar with how the actual "isupper" standard function is
implemented, but I didn't want to clutter up the example with a huge
256-item array with 1s and 0s in it, making it even more obscure.
(Actually, the standard C library uses bit masking to signal different
character types, but I guess had I asked for that, I'd get the first
fascicule of the Ada standard from my valuable coder friends here :-D)

In other words, I wanted to keep things simple.

Still, I should be grateful since you're my first colleague in this
thread to show me:

> ... To convert to and from integers, use the 'Pos
> and 'Val attributes.  If C is a Character and N is an Integer,
>    N := Character'Pos(C);
>    C := Character'Val(N);
> will do the conversions you want.

and also to code the Ada counterpart of the function like so:

>
>    function IsUpper (C : Character) return Boolean is
>       UCASE : constant String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>    begin
>       return C = UCASE (UCASE'First + (Character'Pos(C) mod
> Character'Pos('A')) mod 26);
>    end IsUpper;
>
> Note that arrays do not automatically begin at offset 0 (and String
> types cannot begin at offset 0), which is why UCASE'First is added to
> the index.

I am aware of these.

>
> Note also that this function returns a Boolean, not an
> Integer---Boolean is another enumeration type with values (FALSE,
> TRUE).

I am also aware of these, but I wanted to ignore those details as well.

>
> This isn't a complete translation of your program---I haven't gone into
> how to get at the command-line arguments---but hopefully it will get
> you started.
>

That wasn't the important part.

I guess since yours is the only example, I'll have to settle for it.

Many thanks. Appreciated.


-- KE




  reply	other threads:[~2006-11-15 23:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-15 22:00 Char type verification KE
2006-11-15 21:57 ` Georg Bauhaus
2006-11-15 23:15   ` KE
2006-11-16  4:48     ` Jeffrey R. Carter
2006-11-16 19:53       ` Adam Beneschan
2006-11-16 23:30       ` Yves Bailly
2006-11-17  0:48         ` Jeffrey R. Carter
2006-11-17  1:59           ` Adam Beneschan
2006-11-17 11:30           ` Stephen Leake
2006-11-17 15:33             ` KE
2006-11-17 15:10               ` Georg Bauhaus
2006-11-17 18:30               ` Ludovic Brenta
2006-11-18  2:29                 ` Brian May
2006-11-17 19:45               ` Jeffrey R. Carter
     [not found]               ` <mQm7h.8782$ig4.3262@newsread2.news.pas.earthlink.net>
2006-11-17 19:56                 ` Jeffrey R. Carter
     [not found]                   ` <omz7h.222$1s6.165@newsread2.news.pas.earthlink.net>
2006-11-19  2:19                     ` OT: French Idioms (was Re: Char type verification) Jeffrey R. Carter
2006-11-19  9:04                       ` Dmitry A. Kazakov
2006-11-17 21:22         ` Char type verification Simon Wright
2006-11-17 23:59           ` Yves Bailly
2006-11-15 23:23 ` Simon Wright
2006-11-15 23:33   ` KE
2006-11-16  4:52     ` Jeffrey R. Carter
2006-11-15 23:36 ` Adam Beneschan
2006-11-15 23:55   ` KE [this message]
2006-11-16  4:54     ` Jeffrey R. Carter
2006-11-16  1:08 ` jimmaureenrogers
2006-11-16  1:45   ` KE
2006-11-16  2:15     ` jimmaureenrogers
2006-11-16  2:42     ` Steve Whalen
2006-11-16  9:36     ` Alex R. Mosteo
2006-11-16  7:02 ` KE
2006-11-16 17:04   ` Dmitry A. Kazakov
2006-11-16 22:43   ` Brian May
  -- strict thread matches above, loose matches on Subject: below --
2006-11-16 16:01 Anh Vo
replies disabled

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