DEV Community

Discussion on: Daily Challenge #206 - Pound Means Backspace

Collapse
 
camdez profile image
Cameron Desautels

A quick Clojure solution, leveraging a (linked) list as a stack:

(defn clean-string [s]
  (->> (reduce #(if (= \# %2) (pop %1) (conj %1 %2)) '() s)
       (reverse)
       (apply str)))