Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Rep-string/CLU/rep-string.clu
Normal file
28
Task/Rep-string/CLU/rep-string.clu
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue