Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Functional programming in Ada

29 views
Skip to first unread message

Harald Korneliussen

unread,
Jul 3, 2008, 3:36:24 PM7/3/08
to
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

georg...@gmail.com

unread,
Jul 4, 2008, 12:42:17 AM7/4/08
to

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

0 new messages