Last active
February 10, 2021 16:18
-
-
Save stuartstein777/0cc2b203788a1294b0a0405ffeb52203 to your computer and use it in GitHub Desktop.
remove keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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