clojure prewalk with select-keys -
(clojure.walk/prewalk #(if (map? %) (select-keys % [:c]) %) {:a 1 :b [{:c 3} {:d 4}] :c 5}) =>{:c 5}
why find {:c 5}
, not {:c 3}
? i'm trying write pull out key/value pairs exist form , @ level key specify.
when function called with
{:c 5, :b [{:c 3} {:d 4}], :a 1}
...it returns:
{:c 5}
...thus discarding other keys, including :b
branch, not traversed.
Comments
Post a Comment