Skip to content

Instantly share code, notes, and snippets.

@stuartstein777
Last active February 10, 2021 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartstein777/0cc2b203788a1294b0a0405ffeb52203 to your computer and use it in GitHub Desktop.
Save stuartstein777/0cc2b203788a1294b0a0405ffeb52203 to your computer and use it in GitHub Desktop.
remove keys
(defn remove-keys [m keys]
(if (seq keys)
(recur (dissoc m (first keys)) (rest keys))
m))
(let [test-img-map {:row1-col1 0
:row1-col2 0
:row1-col3 0
:row2-col1 0
:row2-col2 0
:row2-col3 0
:row2-col4 0
:row3-col1 0
:row3-col2 0}
keys-to-remove (->> (keys test-img-map)
(map str)
(filter #(str/starts-with? % ":row2"))
(map #(subs % 1))
(map keyword))]
(remove-keys test-img-map keys-to-remove))
=>>{:row3-col2 0, :row3-col1 0, :row1-col3 0, :row1-col2 0, :row1-col1 0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment