Rep-string: Difference between revisions

Add Clojure
(Add Clojure)
Line 675:
0
1 is no rep string!</pre>
 
=={{header|Clojure}}==
<lang lisp>(defn rep-string [s]
(let [len (count s)
first-half (subs s 0 (/ len 2))
test-group (take-while seq (iterate butlast first-half))
test-reptd (map (comp #(take len %) cycle) test-group)]
(some #(= (seq s) %) test-reptd)))</lang>
{{out}}
<lang lisp>
(def tests-strings ["1001110011"
"1110111011"
"0010010010"
"1010101010"
"1111111111"
"0100101101"
"0100100"
"101"
"11"
"00"
"1"])
 
(map (juxt identity rep-string) test-strings)
</lang>
<pre>
(["1001110011" true]
["1110111011" true]
["0010010010" true]
["1010101010" true]
["1111111111" true]
["0100101101" nil]
["0100100" true]
["101" nil]
["11" true]
["00" true]
["1" nil])
</pre>
 
=={{header|Common Lisp}}==
15

edits