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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8f802583e5c84fa X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed-east.nntpserver.com!nntpserver.com!newsfeed-west.nntpserver.com!news1.optus.net.au!optus!newsfeeder.syd.optusnet.com.au!news.optusnet.com.au!newsfeed.pacific.net.au!nasal.pacific.net.au!not-for-mail Newsgroups: comp.lang.ada Subject: Re: String filtering From: David Trudgett Organization: Very little? References: Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:sWgR6ZDcXpvbqIWstdLjI2RrpWE= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 28 Sep 2005 11:29:19 +1000 NNTP-Posting-Host: 61.8.35.118 X-Complaints-To: news@pacific.net.au X-Trace: nasal.pacific.net.au 1127871237 61.8.35.118 (Wed, 28 Sep 2005 11:33:57 EST) NNTP-Posting-Date: Wed, 28 Sep 2005 11:33:57 EST Xref: g2news1.google.com comp.lang.ada:5216 Date: 2005-09-28T11:29:19+10:00 List-Id: "Jeffrey R. Carter" writes: > David Trudgett wrote: > > It seems odd to do this: > >> New_Str : Unbounded_String >> := To_Unbounded_String(Count(Str, Alphanumeric_Set)); > > if you're also going to do this: > >> New_Str := To_Unbounded_String(""); > >> Append(New_Str, Element(Str, Char)); > > If you allocate the expected length (and not overwrite that with a > null string), then you can use Replace_Element. Yes, it does seem odd. As it happens, the code is easier and shorter that way, but <> might free storage in some implementations, so I created a new version using Replace_Element instead. > > Is there some reason you're not doing this in place, using Delete? Repeated deletes would cause a lot of copying (though not a problem for my particular purposes at present). Now, go away or I shall taunt you a second time! ;-) David P.S. Thanks everyone for your comments on this one. Stay tuned for the next exciting function call! :-) -- David Trudgett http://www.zeta.org.au/~wpower/ "While the popular understanding of anarchism is of a violent, anti-State movement, anarchism is a much more subtle and nuanced tradition than a simple opposition to government power. Anarchists oppose the idea that power and domination are necessary for society, and instead advocate more co-operative, anti-hierarchical forms of social, political and economic organisation." -- The Politics of Individualism, p. 106