specter

Nundrum 2024-10-29T22:12:05.002589Z

I'm just starting out with Specter, so this is probably an easy question. I have a hashmap and a set of keys to remove from it. But can't quite figure out how to navigate to the keys based on that set.

2024-10-30T12:46:44.419439Z

I am still a specter noob myself, but I am putting how I would do this so maybe others can point out better ways to do this

(sp/setval [sp/ALL (fn [[k _]] (#{:a :b} k))] sp/NONE {:a 1 :b 2 :c 3})
=> {:c 3}

Nundrum 2024-10-30T12:58:06.407719Z

Thanks. I feed doubly silly because what was holding me back from the right answer was passing the params to clojure.set/difference in the wrong order 😕 In the end, this line worked!

(transform [ATOM :arcs MAP-KEYS diff] NONE hackstate) 
Which is so much nicer than the doseq version I temporarily worked with.

❤️ 1
steveb8n 2024-10-30T00:06:56.390889Z

There's a few ways, one is MAP-KEYS #{:k1 :k2} as path for setval NONE