Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/String-matching/PL-I/string-matching-1.pli
Normal file
11
Task/String-matching/PL-I/string-matching-1.pli
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/* Let s be one string, t be the other that might exist within s. */
|
||||
/* 8-1-2011 */
|
||||
k = index(s, t);
|
||||
if k = 0 then put skip edit (t, ' is nowhere in sight') (a);
|
||||
else if k = 1 then
|
||||
put skip edit (t, ' starts at the beginning of ', s) (a);
|
||||
else if k+length(t)-1 = length(s) then
|
||||
put skip edit (t, ' is at the end of ', s) (a);
|
||||
else put skip edit (t, ' is within ', s) (a);
|
||||
|
||||
if k > 0 then put skip edit (t, ' starts at position ', k) (a);
|
||||
20
Task/String-matching/PL-I/string-matching-2.pli
Normal file
20
Task/String-matching/PL-I/string-matching-2.pli
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* Handle multiple occurrences. */
|
||||
n = 1;
|
||||
do forever;
|
||||
k = index(s, t, n);
|
||||
if k = 0 then
|
||||
do;
|
||||
if n = 1 then put skip list (t, ' is nowhere in sight');
|
||||
stop;
|
||||
end;
|
||||
else if k = 1 then
|
||||
put skip edit ('<', t, '> starts at the beginning of ', s) (a);
|
||||
else if k+length(t)-1 = length(s) then
|
||||
put skip edit ('<', t, '> is at the end of ', s) (a);
|
||||
else put skip edit ('<', t, '> is within ', s) (a);
|
||||
n = k + length(t);
|
||||
|
||||
if k > 0 then
|
||||
put skip edit ('<', t, '> starts at position ', trim(k)) (a);
|
||||
else stop;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue