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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,341730abd589d6e9 X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Re: string operations Date: 2000/11/18 Message-ID: <3A16C006.B79A599@acm.org>#1/1 X-Deja-AN: 695148892 Content-Transfer-Encoding: 7bit References: <3A16A4D5.CE941970@t-online.de> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 974569601 165.121.234.130 (Sat, 18 Nov 2000 09:46:41 PST) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 NNTP-Posting-Date: Sat, 18 Nov 2000 09:46:41 PST Newsgroups: comp.lang.ada Date: 2000-11-18T00:00:00+00:00 List-Id: Margit Gut wrote: > I try to read a string from the keyboard and then I want to write a > recursiv function to turn the characters from the end to the beginning. The requirement that this be a recursive function sounds like a homework problem. > > I fetch the string with Get_Line. I declared the string with > Sstring : string(1..255); > So whatever I try, the string'Length is always 255. Given the declaration S : String (1 .. 255); S'Length is always 255. This is the definition of the 'Length attribute on an array object. Look carefully at the description of Get_Line in the ARM (A.10.7), especially the meaning of the Last parameter, and then read about slices (ARM 4.1.2). You can find the ARM on line at http://www.adapower.com/rm95/index.html If the string read by Get_Line is shorter than its Item parameter, it is stored in Item (Item'First .. Last). Thus, after executing Get_Line (Item => S, Last => Last); the string of interest is in the slice S (S'First .. Last) > My next poblem is, how to do a correct Function, that calls itselve. A function calls itself exactly the same way that any other statement calls the function: function F (N : Positive) return Positive is begin -- F if N <= 1 then return N; else return N * F (N - 1); end if; end F; -- Jeff Carter "You tiny-brained wipers of other people's bottoms!" Monty Python & the Holy Grail