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

@ -0,0 +1,83 @@
* Tokenize a string - 08/06/2018
TOKSTR CSECT
USING TOKSTR,R13 base register
B 72(R15) skip savearea
DC 17F'0' savearea
SAVE (14,12) save previous context
ST R13,4(R15) link backward
ST R15,8(R13) link forward
LR R13,R15 set addressability
MVC N,=A(1) n=1
LA R7,1 i1=1
LA R6,1 i=1
DO WHILE=(C,R6,LE,LENS) do i=1 to length(s);
LA R4,S-1 @s-1
AR R4,R6 +i
MVC C,0(R4) c=substr(s,i,1)
IF CLI,C,EQ,C',' THEN if c=',' then do
BAL R14,TOK call tok
LR R2,R8 i2
SR R2,R7 i2-i1
LA R2,1(R2) i2-i1+1
L R1,N n
SLA R1,1 *2
STH R2,TALEN-2(R1) talen(n)=i2-i1+1
L R2,N n
LA R2,1(R2) n+1
ST R2,N n=n+1
LA R7,1(R6) i1=i+1
ENDIF , endif
LA R6,1(R6) i++
ENDDO , enddo i
BAL R14,TOK call tok
LR R2,R8 i2
SR R2,R7 i2-i1
LA R2,1(R2) i2-i1+1
L R1,N n
SLA R1,1 *2
STH R2,TALEN-2(R1) talen(n)=i2-i1+1
LA R11,PG pgi=@pg
LA R6,1 i=1
DO WHILE=(C,R6,LE,N) do i=1 to n
LR R1,R6 i
SLA R1,1 *2
LH R10,TALEN-2(R1) l=talen(i)
LR R1,R6 i
SLA R1,3 *8
LA R4,TABLE-8(R1) @table(i)
LR R2,R10 l
BCTR R2,0 ~
EX R2,MVCX output table(i) length(l)
AR R11,R10 pgi=pgi+l
IF C,R6,NE,N THEN if i^=n then
MVC 0(1,R11),=C'.' output '.'
LA R11,1(R11) pgi=pgi+1
ENDIF , endif
LA R6,1(R6) i++
ENDDO , enddo i
XPRNT PG,L'PG print
L R13,4(0,R13) restore previous savearea pointer
RETURN (14,12),RC=0 restore registers from calling sav
TOK LR R5,R6 i <--
BCTR R5,0 i-1 |
LR R8,R5 i2=i-1
SR R5,R7 i2-i1
LA R5,1(R5) l=i2-i1+1 source length
L R1,N n
SLA R1,3 *8
LA R2,TABLE-8(R1) @table(n)
LA R4,S-1 @s-1
AR R4,R7 @s+i1-1
LA R3,8 target length
MVCL R2,R4 table(n)=substr(s,i1,i2-i1+1) |
BR R14 End TOK subroutine <--
MVCX MVC 0(0,R11),0(R4) output table(i)
S DC CL80'Hello,How,Are,You,Today' <== input string ==
LENS DC F'23' length(s) <==
TABLE DC 8CL8' ' table(8)
TALEN DC 8H'0' talen(8)
C DS CL1 char
N DS F number of tokens
PG DC CL80' ' buffer
YREGS
END TOKSTR

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;

View file

@ -1,3 +1,3 @@
let text = 'Hello,How,Are,You,Today'
let tokens = text.split /,/
print join('.', tokens)
let tokens = text.split(/,/)
print tokens.join(with: '.')

View file

@ -0,0 +1,13 @@
/* created by Aykayayciti Earl Lamont Montgomery
April 9th, 2018 */
a = []
a = strSplit("Hello,How,Are,You,Today", ",")
index = 0
start = 0
b = ""
for index in [ start : len(a)-1 : 1 ]
b = b + a[index] + "."
end
> b

View file

@ -0,0 +1,6 @@
Public Sub Main()
Dim sString As String[] = Split("Hello,How,Are,You,Today")
Print sString.Join(".")
End

View file

@ -0,0 +1 @@
StringTools:-Join(StringTools:-Split("Hello,How,Are,You,Today", ","),".");

View file

@ -0,0 +1,4 @@
s := 'Hello,How,Are,You,Today'
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|H|e|l|l|o|,|H|o|w|,|A|r|e|,|Y|o|u|,|T|o|d|a|y|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

View file

@ -0,0 +1,6 @@
t := s eachall = `, cut s
+-----------+-------+-------+-------+-----------+
|+-+-+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+-+-+|
||H|e|l|l|o|||H|o|w|||A|r|e|||Y|o|u|||T|o|d|a|y||
|+-+-+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+|+-+-+-+-+-+|
+-----------+-------+-------+-------+-----------+

View file

@ -0,0 +1,4 @@
u := front content (cart t `.)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|H|e|l|l|o|.|H|o|w|.|A|r|e|.|Y|o|u|.|T|o|d|a|y|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

View file

@ -0,0 +1,8 @@
s:='Hello,How,Are,You,Today'
Hello,How,Are,You,Today
t:= s eachall = `, cut s
+-----+---+---+---+-----+
|Hello|How|Are|You|Today|
+-----+---+---+---+-----+
u:=front content (cart t `.)
Hello.How.Are.You.Today

View file

@ -0,0 +1,8 @@
str: "Hello,How,Are,You,Today"
>> tokens: split str ","
>> probe tokens
["Hello" "How" "Are" "You" "Today"]
>> periods: replace/all form tokens " " "." ;The word FORM converts the list series to a string removing quotes.
>> print periods ;then REPLACE/ALL spaces with period
Hello.How.Are.You.Today

View file

@ -0,0 +1,13 @@
Sub Main()
Dim temp() As String
temp = Tokenize("Hello,How,Are,You,Today", ",")
Display temp, Space(5)
End Sub
Private Function Tokenize(strS As String, sep As String) As String()
Tokenize = Split(strS, sep)
End Function
Private Sub Display(arr() As String, sep As String)
Debug.Print Join(arr, sep)
End Sub