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