Rep-string: Difference between revisions

1,080 bytes added ,  10 years ago
Initial implememtation in PL/I
(Initial implememtation in PL/I)
Line 545:
}
}</lang>
 
=={{header|PL/I}}==
<lang PL/I>rep: procedure options (main); /* 5 May 2015 */
declare s bit (10) varying;
declare (i, k) fixed binary;
 
main_loop:
do s = '1001110011'b, '1110111011'b, '0010010010'b, '1010101010'b,
'1111111111'b, '0100101101'b, '0100100'b, '101'b, '11'b, '00'b, '1'b;
k = length(s);
do i = k/2 to 1 by -1;
if substr(s, 1, i) = substr(s, i+1, i) then
do;
put skip edit (s, ' is a rep-string containing ', substr(s, 1, i) ) (a);
iterate main_loop;
end;
end;
put skip edit (s, ' is not a rep-string') (a);
end;
 
end rep;</lang>
Output:
<pre>
1001110011 is a rep-string containing 10011
1110111011 is a rep-string containing 1110
0010010010 is a rep-string containing 001
1010101010 is a rep-string containing 1010
1111111111 is a rep-string containing 11111
0100101101 is a rep-string containing 010
0100100 is a rep-string containing 010
101 is not a rep-string
11 is a rep-string containing 1
00 is a rep-string containing 0
1 is not a rep-string
</pre>
 
=={{header|Python}}==