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,aab48c153d1e916b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!cyclone1.gnilink.net!gnilink.net!wns13feed!worldnet.att.net!attbi_s04.POSTED!53ab2750!not-for-mail From: "Steve" Newsgroups: comp.lang.ada References: <40f684a8@dnews.tpgi.com.au> Subject: Re: questions from a newbie X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: <0UvJc.83034$MB3.55228@attbi_s04> NNTP-Posting-Host: 24.21.42.251 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s04 1089899132 24.21.42.251 (Thu, 15 Jul 2004 13:45:32 GMT) NNTP-Posting-Date: Thu, 15 Jul 2004 13:45:32 GMT Organization: Comcast Online Date: Thu, 15 Jul 2004 13:45:32 GMT Xref: g2news1.google.com comp.lang.ada:2184 Date: 2004-07-15T13:45:32+00:00 List-Id: "zork" wrote in message news:40f684a8@dnews.tpgi.com.au... > Hi, I just started a course in ada. I just have 2 questions at present. > > ------------- > q1) can: > > c : character; > > if c in 'A'..'Z' or c in 'a'..'z' or c in '0'..'9' then > .... > end if; > > be written as something like: > > c : character; > > if c in ('A'..'Z', 'a'..'z', '0'..'9') then > .... > end if; > ------------- Not directly, but you can make use the of standard Ada libraries: Ada.Strings.Maps Ada.Strings.Maps.Constants and do something like: if Is_In( c, Alphanumeric_Set ) then ... end if; Since you're a newbie, I recommend you peruse annex A of the Ada 95 reference manual; it describes the predefined language enviroment, which is basically a list of all of the standard libraries. You can download a copy from: http://www.adaic.org/standards/ada95.html > > Also, I know you can do the following: > > type new_type is array(1..20) of string(1..50); > words : new_type; > index : integer := 20; > words (15) (index ..index) := "K"; > > however I find that I cannot instead say: > > words(15)(index):="K"; > > why is this so? I get a "Type mismatch in assignment statement, continuing" > error. It does however work when I use words(15)(index):='K'. The rational > behind this is that (index..index) represents a range - hence a string - > whereas (index) represents a single character? > You answered your own question here. If you're coming from a different programming language, you may find that Ada is kind of a "hard ass" about the syntax it will accept. When you get over the frustration and find that more programs work correctly after you get past the compiler, you may never want to go back. Steve (The Duck) > Any insight most helpful. > > Cheers, > zork > >