June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,24 +1,17 @@
with Ada.Text_IO, Ada.Strings.Fixed, Ada.Containers.Indefinite_Vectors;
use Ada.Text_IO, Ada.Strings.Fixed, Ada.Containers;
with Ada.Text_IO, Ada.Containers.Indefinite_Vectors;
use Ada.Text_IO, Ada.Containers;
procedure tokenize is
package String_Vector is new Indefinite_Vectors (Natural,String); use String_Vector;
procedure Parse (s : String; v : in out Vector) is
i : Integer := Index (s,",");
begin
if s'Length > 0 then
if i < s'First then
v.Append (s);
else
v.Append (s (s'First..i-1));
Parse ( s(i+1..s'Last), v);
end if;
end if;
end Parse;
v : Vector;
s : String := "Hello,How,Are,You,Today" & ",";
current : Positive := s'First;
v : Vector;
begin
Parse ("Hello,How,Are,You,Today,,",v);
for s of v loop
put(s&".");
end loop;
for i in s'range loop
if s (i) = ',' or i = s'last then
v.append (s (current .. i-1));
current := i + 1;
end if;
end loop;
for s of v loop put(s & "."); end loop;
end tokenize;