Fork me on GitHub
#specter
<
2018-06-14
>
nathanmarz03:06:05

@jsa-aerial with walker it's:

(let [replacements {:b 77 :x :xxx}]
  (transform [(walker (complement coll?)) #(contains? replacements %)]
    replacements
    data
    ))

nathanmarz03:06:20

better than doing recursion manually in my opinion

jsa-aerial05:06:50

💯 ah...

lispyclouds15:06:20

Hello, I have the following structure

lispyclouds15:06:35

and a function (get-details) which does url -> [detailed-url1, detailed-url2 …]

lispyclouds15:06:53

What i need is the following

lispyclouds15:06:59

This is what Im using currently

(defn categorized-urls []
  (->> (input)
       (transform [ALL MAP-VALS ALL MAP-VALS ALL] get-details)
       (transform [ALL MAP-VALS ALL MAP-VALS] flatten)))

lispyclouds15:06:16

Is there a better way?

lispyclouds15:06:41

The input structure is pretty huge and its taking a while to execute this. Was wondering there might be a better way than twice transforms.

nathanmarz15:06:59

@rahul080327 this will speed it up:

(defn categorized-urls [input]
  (multi-transform
    [ALL
     MAP-VALS
     ALL
     MAP-VALS
     (multi-path
       [ALL (terminal get-details)]
       (terminal #(into [] (mapcat identity) %)))]
    input))

nathanmarz15:06:14

traverses the data structure once instead of twice

lispyclouds15:06:10

Ahan thanks a lot @nathanmarz superb 😃