Skip to content

Instantly share code, notes, and snippets.

View spariev's full-sized avatar

Sergey Pariev spariev

  • Kyiv
View GitHub Profile
(defn cc-rev
[s]
(let [paren? (fn [ch] (or (= ch \() (= ch \))))]
(apply str
(concat
(flatten
(->> s
(partition-by paren?)
(remove #(paren? (first %)))
(map-indexed (fn [idx ss] (if (odd? idx) (reverse ss) ss)))))))))