tests = [ '1001110011' '1110111011' '0010010010' '1010101010' '1111111111' '0100101101' '0100100' '101' '11' '00' '1' ] F is_repeated(s:Str) (s.len()/2..0).first(F(x) s.starts_with(s[x..null])) { tests.each(F(test) { local r = is_repeated(test) echo("${test} ${if r "has repetition of length ${r} (i.e. ${test[0..r]})" "is not a rep-string"}") }) }