specter

Latest version: 1.1.3
nonrecursive 2020-04-13T03:47:32.008700Z

hey hey ๐Ÿ™‚ How would I return a map where all paths that donโ€™t terminate in an integer have been pruned? Given:

{:a {:b {:c 10
         :d ""}}
 :f 5
 :k [10]
 :m ""
 :x {:y {:z ""}}}
I want:
{:a {:b {:c 10}}
 :f 5
 :k [10]}

nathanmarz 2020-04-13T22:36:24.009700Z

@nonrecursive you can do that with a custom walker and compact :

(def COMPACTING-WALKER
  (recursive-path [] p
    (cond-path map? [(compact MAP-VALS) p]
               coll? [(compact ALL) p]
               STAY STAY
               )))

(setval [COMPACTING-WALKER (complement number?)]
  NONE
  data
  )

๐Ÿ’ฏ 1