Quantcast
Channel: Update multiple elements of a Clojure atom - Stack Overflow
Browsing index pages (3 articles)
↧

Update multiple elements of a Clojure atom

I have a atom: (def data (atom[ {:orderid 0 :productid 0 :description "A" :amount 2} {:orderid 1 :productid 1 :description "A" :amount 2}]))and my swap function: (defn edit-order [params] (filter #(and...

View Article


Answer by Michiel Borkent for Update multiple elements of a Clojure atom

The way to go about this is:(def data (atom [{:orderid 0 :productid 0 :description "A" :amount 2} {:orderid 1 :productid 1 :description "A" :amount 2}]))(defn edit-order [params] (swap! data (fn...

View Article


Answer by Markc for Update multiple elements of a Clojure atom

Another option, if you're doing a lot of nested structure manipulation, is to use https://github.com/nathanmarz/specter, in this case the "transform" operation.(ns specterplay.core (:require...

View Article
Browsing index pages (3 articles)


Latest Images