Given a card with a key: content, where the content is a list of lines or other cards, how can I flatten values to get only lines?
(flattener {:content '("b" {:content ("c" {:content ("d")})} "e")}) > '("b" "c" "d" "e")
I stumble upon attempts to intercept hacker cycles, and now my brain is burned out. Is there a good idiomatic way to do this in Clojure?
Thanks.
What I have is below, and although it works, it is pretty ugly
(defn flatten-content [coll] (loop [acc '(), l coll] (let [fst (first l), rst (rest l)] (cond (empty? l) (reverse acc) (seq? fst) (recur acc (concat fst rst)) (associative? fst) (recur acc (concat (:content fst) rst)) :else (recur (conj acc fst) rst)))))
Scott source share