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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a10f82bbb9765a8c X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!postnews.google.com!m73g2000hsh.googlegroups.com!not-for-mail From: george.priv@gmail.com Newsgroups: comp.lang.ada Subject: Re: Functional programming in Ada Date: Thu, 3 Jul 2008 21:42:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: <25c0d9d8-49ff-4d26-afe5-9b7195136b19@m73g2000hsh.googlegroups.com> References: <6d36b873-15e1-4c5d-ae46-c5b7a6b5bf50@m3g2000hsc.googlegroups.com> NNTP-Posting-Host: 166.217.129.242 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1215146537 20456 127.0.0.1 (4 Jul 2008 04:42:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 4 Jul 2008 04:42:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m73g2000hsh.googlegroups.com; posting-host=166.217.129.242; posting-account=VnNb3AoAAACTpRtCcTrcjmPX7cs92k1Q User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1001 Date: 2008-07-03T21:42:17-07:00 List-Id: On Jul 3, 3:36 pm, Harald Korneliussen wrote: > FP guru Chris Okasaki wrote an interesting post on doing functional > programming in Ada. Perhaps mostly a curiosity, but interesting that > it can be done. > > http://okasaki.blogspot.com/2008/07/functional-programming-inada.html More fun with splitting/concatenating arrays: with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Fixed; type Tokens is array (Integer range <>) of Unbounded_String; function Tokenize (Src : String) return Tokens is Idx : Integer := Ada.Strings.Fixed.Index (Src, " "); begin if Idx >= Src'First then return To_Unbounded_String (Src(Src'First..Idx)) & Tokenize (Src(Idx+1..Src'Last)); else return X : Tokens (1..1) do X(1) := To_Unbounded_String (Src); end return; end if; end Tokenize; Reminds me old days fulling around with Prolog.. George