This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-18
Channels
- # ai (1)
- # beginners (71)
- # boot (15)
- # cider (26)
- # clara (4)
- # cljs-dev (81)
- # cljsrn (26)
- # clojure (393)
- # clojure-berlin (2)
- # clojure-dev (5)
- # clojure-dusseldorf (1)
- # clojure-greece (5)
- # clojure-italy (6)
- # clojure-russia (97)
- # clojure-serbia (11)
- # clojure-sg (2)
- # clojure-spec (14)
- # clojure-uk (66)
- # clojurescript (58)
- # core-async (19)
- # cursive (18)
- # data-science (2)
- # datomic (75)
- # emacs (20)
- # events (5)
- # figwheel (1)
- # graphql (2)
- # hoplon (29)
- # jobs-discuss (3)
- # juxt (6)
- # lein-figwheel (1)
- # london-clojurians (2)
- # lumo (29)
- # mount (9)
- # off-topic (4)
- # om (16)
- # onyx (25)
- # other-languages (2)
- # pedestal (38)
- # protorepl (2)
- # re-frame (20)
- # reagent (9)
- # ring-swagger (6)
- # sql (10)
- # unrepl (3)
- # untangled (19)
- # utah-clojurians (1)
- # videos (2)
- # vim (20)
is there something that shows you the "shape" of a var in the repl?
e.g. some var may hold a map of lists of maps or so on, and groping it with multiple keys
count
and take
so as to see its structure without thousands of console output lines (when the data structure is beyond very small) is rather tedious of course.
there’s clojure.inspector/inspect
oops, sorry - I meant inspect-tree
@alexmiller ah! great, thanks again!
I tried the above, and it only sends an unrealized lazy seq to stdout/stderr. Any idea?
because that’s how lazy seqs print, regardless of realization
this bounded printing capability is actually built into the printer
(binding [*print-length* 4] (print-str (range 1000)))
so in your code you could replace with something like (binding [*print-length* 4] (print-str coll))
well, it depends. with str
, no.
the printer will do various things in various circumstances
thanks a lot! I'd never realize there's print-str to use for that! now I see the differences between the two 🙂
there are untold wonders in the printing system :)
I wish they were a little less untold :)
hey, i’m using a library that works with a promise
, and i want to listen for the delivery of that promise and invoke a callback when it’s delivered
But you might be able to learn something from promesa (or use it): https://funcool.github.io/promesa/latest/#promise-chaining
@lmergen if you use an atom, ref, or agent instead of a promise you can attach a watch that will execute when it takes on a new value
Any clojure.core or particularly idiomatic way of merging maps while failing if keys repeat?
I was thinking of using merge-with
for it, unless there's already something.
what kind of fail?
You're trying to merge a non-map with a map? Otherwise you shouldn't have dup keys, right?
both maps have the same key
(merge-with (fn [& _] (throw (Exception. "duplicate key"))) x y)
sadly merge-with doesn’t see the key that overlapped
(if-let [dups (set/intersection (keys x) (keys y))] (throw (ex-info "duplicate keys" {:keys dups})) (merge x y))
ex-info is cool
but I would do the merge first, only calculate the intersection on failure (performance...)
you can use ex-data to get the data arg passed to ex-info in a catch block
ahh - so you could merge-with, and then calculate the duplicated keys inside the merging function