Rep-string: Difference between revisions

Content added Content deleted
(add RPL)
(Add SETL)
Line 4,245: Line 4,245:
No rep-string for "1"
No rep-string for "1"
</pre>
</pre>

=={{header|SETL}}==
<syntaxhighlight lang="setl">program repstring;
tests := [
"1001110011", "1110111011", "0010010010", "1010101010",
"1111111111", "0100101101", "0100100", "101", "11", "00", "1"
];

loop for test in tests do
print(test + ": " + str repstrings(test));
end loop;

proc repstrings(s);
return {
s(..l) : l in [1..#s div 2]
| (s(..l)*(#s div l+1))(..#s) = s
};
end proc;
end program;</syntaxhighlight>
{{out}}
<pre>1001110011: {'10011'}
1110111011: {'1110'}
0010010010: {'001'}
1010101010: {'10' '1010'}
1111111111: {'1' '11' '111' '1111' '11111'}
0100101101: {}
0100100: {'010'}
101: {}
11: {'1'}
00: {'0'}
1: {}</pre>


=={{header|Sidef}}==
=={{header|Sidef}}==