I have a map that looks like this:
{\a [\h]
\h [\w \w]
\i [\w \h \t]
\p [\t \u \h \a]
\s [\t \a \t \t \i \w \h]
\t [\a]
\u [\t \t \s]
\w []}
I want to remove e.g. \w from both keys and values. i.e. leaving this
{\a [\h]
\h []
\i [\h \t]
\p [\t \u \h \a]
\s [\t \a \t \t \i \h]
\t [\a]
\u [\t \t \s]}
Notice, the \w key has gone and \w has gone from all the values!
Right now I have this, which works, but I'm sure there must be a better, more Clojurey way!
(defn remove-last [last cmap]
(reduce-kv (fn [acc k v]
(if (empty? v)
acc
(into acc {k (vec (filter #(not= % last) v))}))) {} cmap))
The key to remove will always be an empty vector.
How can I do this better?