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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d955a56d21742fee X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-19 16:31:59 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!cox.net!newspeer1-gui.server.ntli.net!ntli.net!news6-win.server.ntlworld.com.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: <3ce7c19a@news.comindico.com.au> <3ce81da1$1@news.comindico.com.au> Subject: Re: An example was Re: Tokens X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Mon, 20 May 2002 00:30:29 +0100 NNTP-Posting-Host: 62.255.157.109 X-Complaints-To: abuse@ntlworld.com X-Trace: news6-win.server.ntlworld.com 1021851031 62.255.157.109 (Mon, 20 May 2002 00:30:31 BST) NNTP-Posting-Date: Mon, 20 May 2002 00:30:31 BST Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:24393 Date: 2002-05-20T00:30:29+01:00 List-Id: "chris.danx" wrote in message news:dkWF8.34770$Iv.4001930@news6-win.server.ntlworld.com... Hi, Is there a cheap way to prevent the last "&" from being printed in the code below? I can think of several options but all of them require an additional call to find_token or switching to a loop. Is there another way that doesn't have a repeated call to find token? Since it's just an example there's no real harm done, it's just annoying that's all!!! Chris > procedure what_words (str : in string; > delims : in maps.character_set) is > first : positive := 1; > last : natural := 0; > begin > fixed.find_token (str, > delims, > ada.strings.outside, > first, > last); > > -- if last = 0 there are no more tokens, so we stop, > -- otherwise we recur! > -- > if last > 0 then > ada.text_io.put (str(first..last) & " & "); > > what_words (str (last + 1..str'last), > delims); > end if; > end what_words;