Rep-string: Difference between revisions

Add CLU
(Added solution for Action!)
(Add CLU)
Line 1,008:
["1" nil])
</pre>
 
=={{header|CLU}}==
<lang clu>rep_strings = iter (s: string) yields (string)
for len: int in int$from_to_by(string$size(s)/2, 1, -1) do
repstr: string := string$substr(s, 1, len)
attempt: string := ""
while string$size(attempt) < string$size(s) do
attempt := attempt || repstr
end
if s = string$substr(attempt, 1, string$size(s)) then
yield(repstr)
end
end
end rep_strings
 
start_up = proc ()
as = array[string]
po: stream := stream$primary_output()
tests: as := as$["1001110011","1110111011","0010010010","1010101010",
"1111111111","0100101101","0100100","101","11","00",
"1"]
for test: string in as$elements(tests) do
stream$puts(po, test || ": ")
for rep_str: string in rep_strings(test) do
stream$puts(po, "<" || rep_str || "> ")
end
stream$putc(po, '\n')
end
end start_up</lang>
{{out}}
<pre>1001110011: <10011>
1110111011: <1110>
0010010010: <001>
1010101010: <1010> <10>
1111111111: <11111> <1111> <111> <11> <1>
0100101101:
0100100: <010>
101:
11: <1>
00: <0>
1:</pre>
 
=={{header|Common Lisp}}==
2,114

edits