langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
22
Task/Binary-strings/PL-I/binary-strings.pli
Normal file
22
Task/Binary-strings/PL-I/binary-strings.pli
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* PL/I has immediate facilities for all those operations except for */
|
||||
/* replace. */
|
||||
s = t; /* assignment */
|
||||
s = t || u; /* catenation - append one or more bytes. */
|
||||
if length(s) = 0 then ... /* test for an empty string. */
|
||||
if s = t then ... /* compare strings. */
|
||||
u = substr(t, i, j); /* take a substring of t beginning at the */
|
||||
/* i-th character andcontinuing for j */
|
||||
/* characters. */
|
||||
substr(u, i, j) = t; /* replace j characters in u, beginning */
|
||||
/* with the i-th character. */
|
||||
|
||||
/* In string t, replace every occurrence of string u with string v. */
|
||||
replace: procedure (t, u, v);
|
||||
declare (t, u, v) character (*) varying;
|
||||
|
||||
do until (k = 0);
|
||||
k = index(t, u);
|
||||
if k > 0 then
|
||||
t = substr(t, 1, k-1) || v || substr(t, k+length(u));
|
||||
end;
|
||||
end replace;
|
||||
Loading…
Add table
Add a link
Reference in a new issue