Fork me on GitHub
#specter
<
2019-10-27
>
nathanmarz13:10:04

@trevor670 that's best done with a reduce

nathanmarz13:10:12

specter can help with the reducing function

nathanmarz13:10:14

(reduce
 (fn [res m]
  (setval [(keypath (:name m))
           :args-list
           NIL->VECTOR
           AFTER-ELEM]
    (:args m)
    res))
  {}
  data)

Trevor20:10:54

Thanks @nathanmarz! I'm really new to clojure and found it so surprising that (map fn coll) doesnt preserve the original map! changes vectors to lists and lazy sequences! Very confusing for a beginner! While it might lead to some gaps in understanding idiomatic clojure, I've been finding spectre a lot easier to read and understand (from the perspective of a new learner) and things behave how I would expect them too! Thanks for making Spectre!

sogaiu22:10:04

@trevor670 fwiw, i also experienced confusion initially, but once i focused on the distinction between collections and sequences, things started to make a lot more sense to me.

Trevor00:10:57

Interesting, I'll keep that in mind!

Ani Banerjee23:10:28

@nathanmarz Need some help with a recursive query: I have a map of maps which which stores top-level entities and entity details:

(def process-db {:process {:p1 {:name "P1"} :p2 {:name "P2"}}
                 :process-flow {:pf1 {:process_id :p1} :pf2 {:process_id :p2}}})
I want to get the process :name navigating from a process-flow-id.
(select [:process-flow MAP-VALS :process_id] process-db)
=> [:p1 :p2]
How do I write a select query that "loops back" to process-db, and does a lookup on
[:process MAP-VALS :name]