保留哈希映射的某些键

Ant*_*ald 2 clojure clojurescript

什么是从哈希映射中仅保留某些键的快速方法?

(def m {:a 1 :b 2 :c 3 :d 4})
Run Code Online (Sandbox Code Playgroud)

显式版本:

((fn [{:keys [b c]}] {:b b :c c})
 m)
;= {:b 2, :c 3}
Run Code Online (Sandbox Code Playgroud)

Lee*_*Lee 7

select-keys:

(select-keys m [:b :c])
Run Code Online (Sandbox Code Playgroud)