RosettaCodeData/Task/Rep-string/Clojure/rep-string-1.clj

7 lines
258 B
Clojure
Raw Permalink Normal View History

2020-02-17 23:21:07 -08:00
(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)))