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!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail Date: Tue, 27 Sep 2005 16:08:36 +0200 From: Georg Bauhaus Organization: future apps GmbH User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050831 Debian/1.7.8-1sarge2 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: String filtering References: <1j92wa9843ylq.16j89wuqatbaj$.dlg@40tude.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4339525d$0$26227$9b4e6d93@newsread2.arcor-online.net> NNTP-Posting-Date: 27 Sep 2005 16:08:29 MEST NNTP-Posting-Host: 3a58cd5d.newsread2.arcor-online.net X-Trace: DXC=gmn26?78JQ5U85hF6f;DjW\KbG]kaMHGSi?jHD8GO@1QBX9:=P9Ihe`BH@Z?dZ]MOidE X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:5195 Date: 2005-09-27T16:08:29+02:00 List-Id: David Trudgett wrote: > Yes, well, functions work that way in Ada (fortunately, or > unfortunately, I don't know). I could have made it a procedure with an > "in out" parameter, but I like functional programming better. > Unfortunately, I haven't been able to do proper functional style > programming in Ada so far, having been thwarted by strong typing and > lack of "out" parameters in functions. Here's a filter then. with Ada.Containers.Vectors; package Character_Vectors is new Ada.Containers.Vectors(Element_Type => Character, Index_Type => Positive); with Character_Vectors; with Ada.Strings.Maps.Constants; procedure filter is use Character_Vectors; input: Vector; output: Vector; procedure save_good_ones(c: Cursor) is use Ada.Strings.Maps; Alpha_Num_Space_Set : constant Character_Set := Constants.Alphanumeric_Set or To_Set(' '); begin if Is_In(Element(c), Alpha_Num_Space_Set) then append(output, Element(c)); end if; end save_good_ones; begin Iterate(input, save_good_ones'access); end filter;