Fork me on GitHub
#beginners
<
2020-11-26
>
eunmin05:11:46

Hi~! Is there a utility that I can get(or assoc) all values in nested map with vector?

(def data
  {:a [{:b {:c [{:d 1}]}}
       {:b {:c [{:d 2}]}}]})

;; It's ok
(get-in data [:a 0 :b :c 0])
=> {:d 1}

;; Like this?
(get-all data [:a :* :b :c :*])
=> [{:d 1} {:d 2}]

;; Like this?
(assoc-all data [:a :* :b :c :* :e] 3)
=> {:a [{:b {:c [{:d 1
               :e 3}]}}
        {:b {:c [{:d 2
               :e 3}]}}]}

drewverlee03:11:17

Im curious what the real situation is. Both libs mentioned will help. But always suspect there is a database issue at play when I see questions like this.

voortuck06:11:55

Has anyone here used etaoin to print a pdf of a web page? Webdriver spec has the command. There are examples here for c# and Java: https://stackoverflow.com/questions/47387776/chromedriver-print-to-pdf-after-page-load#48405542 , but when I look in the code for etaoin I don’t see it implemented. Are there other clojure options?

David Pham10:11:14

Is there a way with transit-clj to serialize sorted-maps?

gon11:11:40

sure, you have to provide your encoding/decoding handlers

David Pham14:11:59

IThanks a lot @gon!

David Pham14:11:09

I have a question about multimethods: if a method is defined in two different namespace wit the dispatch value, and they are both loaded into a new namespace, which one will take precedence?

David Pham14:11:06

I tried in Clojure and it appeared to me that it was the namespace which was imported last (which somehow made sense), but then I tested in ClojureScript and the order was not relevant.

David Pham14:11:21

I am asking because I need to overwrite one of the dispatch function.

st3fan16:11:16

I've turned this week off into Clojure Hack Week

st3fan18:11:51

I guess most people are 🦃 🥧