specter

Latest version: 1.1.3
nathanmarz 2019-10-27T13:46:04.005900Z

@trevor670 that's best done with a reduce

nathanmarz 2019-10-27T13:46:12.006200Z

specter can help with the reducing function

nathanmarz 2019-10-27T13:46:14.006400Z

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

Trevor 2019-10-27T20:35:54.011700Z

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!

2019-10-27T22:49:04.014100Z

@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.

Ani Banerjee 2019-10-27T23:09:28.015100Z

@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]