RosettaCodeData/Task/Rep-string/XPL0/rep-string.xpl0

30 lines
652 B
Plaintext

include xpllib; \for StrLen, StrFind and Print
func RepStr(Str);
char Str;
int SL;
[if Str(0) = 0 then return 0;
SL:= StrLen(Str)/2;
while SL > 0 do
[if StrFind(Str, Str+SL) = Str then
return SL;
SL:= SL-1;
];
return 0;
];
int Strs, I, N;
char PS;
[Strs:= ["1001110011", "1110111011", "0010010010", "1111111111",
"0100101101", "0100100", "101", "11", "00", "1"];
for I:= 0 to 10-1 do
[N:= RepStr(Strs(I));
PS:= "^"%s^" = rep-string ^"%1.0s^"\n";
PS(22):= N+^0; \ 8-)
if N # 0 then
Print(PS, Strs(I), Strs(I))
else
Print("^"%s^" = not a rep-string\n", Strs(I));
];
]