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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1c5054c2af5fc156 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-17 03:44:44 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!128.39.3.168!uninett.no!news.net.uni-c.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Emulation of MatLab functions? Date: Tue, 17 Jul 2001 12:44:43 +0200 Organization: Centre for Chaos and Turbulence Studies, Niels Bohr Institute Message-ID: <3B54171B.8AD28D4@nbi.dk> References: <3B5386B1.AF0E7671@top.monad.net> NNTP-Posting-Host: alf.nbi.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.net.uni-c.dk 995366683 35426 130.225.212.55 (17 Jul 2001 10:44:43 GMT) X-Complaints-To: usenet@news.net.uni-c.dk NNTP-Posting-Date: Tue, 17 Jul 2001 10:44:43 +0000 (UTC) X-Mailer: Mozilla 4.77 [en] (X11; U; OSF1 V4.0 alpha) X-Accept-Language: fo,da,no,sv,is,de,fr,en Xref: archiver1.google.com comp.lang.ada:10052 Date: 2001-07-17T12:44:43+02:00 List-Id: Steve: John Thornley published a sorting package somewhere. Find should be pretty easy to implement. Something along the lines of: -- The following is distributed according to the GNU GPL or the -- ADCL (when it is finished). generic type Element_Type is private; type Element_Array is array (Integer range <>) of Element_Type; with function Match (Item : Element_Type) return Boolean; function Find (Source : Element_Array) return Element_Array; function Find (Source : Element_Array) return Element_Array is Match_Count : Natural := 0; Matches : array (Source'Range) of Boolean; begin for Index in Source'Range loop Matches (Index) := Match (Source (Index)); if Matches (Index) then Match_Count := Match_Count + 1; end if; end loop; declare Result : Element_Array (1 .. Match_Count); Target_Index : Natural := 0; begin for Source_Index in Source'Range loop if Matches (Source_Index) then Target_Index := Target_Index + 1; Result (Target_Index) := Source (Source_Index); end if; end loop; return Result; end; end Find; Jacob -- Warning: Dates in calendars are closer than they appear.