Version 2.0.146 is out with the following fixes 🎉: • Fix: https://github.com/BetterThanTomorrow/calva/issues/883 • Fix: https://github.com/BetterThanTomorrow/calva/issues/906 • Fix: https://github.com/BetterThanTomorrow/calva/issues/884 • Fix: https://github.com/BetterThanTomorrow/calva/issues/888
How can I step by step through a code to see what I really does ?
You mean like in a debugger?
I think so
or did I type the break on the wrong place
(defn validate2
[validators suspect] #break
(reduce-kv (fn[acc k v]
(and acc ;; The previous keys were validated
(contains? suspect k) ;; the suspect contains the key in question
(v (suspect k)))) ;; the value of that key in the suspect validates according to the validator function
true validators))
as soon as I choose to got in the code It seems that the debugging stops
What I do in cases like that (nice small functions) is that I instrument the whole defn. So instead of that #break
, I evaluate the code using the debug instrument command instead of the regular one.
I have noticed that JS objects in the cljs REPL (or rather in the source code, when evaluating an expression there) are printed in an unhelpful way, such as (`|` is the cursor position when I press Alt-Enter):
js/firebase | => :shadow.cljs/print-error!
(.app js/firebase) | => #object[K [object Object]]
(Wrapping the result with js->clj
does not help either.) Is that a known limitation? Thank you!I certainly recognize it. Happens in typescirpt and javascript as well often. Not sure it is the same case, but what I do in TS is that I call JSON.stringify() on the object.
@pez oke back to the docs how to do that
It’s this one: https://calva.io/debugger/#instrumenting-a-function
Another thing I often do is that i def
things in the functions. Doesn’t really help all that much in a reduce, but as a general tool it can be useful.
hmm, wierd, I do `crtl+alt+c and then i but no breaks
That should instrument the function. So that when you run it, it should break. Doesn’t happen?
first not
but when I did `crtl+alt+c and then holding the crtl-alt keys it worked
nice to see how things are working
About that def
technique: https://clojureverse.org/t/exploring-using-def-x-x/3946
thanks,
Now I understand a lilte how this one is working
(defn maps->csv [coll-of-maps]
(let [header (-> coll-of-maps first keys) ;; we take the keys to use as a csv header
to-vals (apply juxt header) ;; a function that will extract the map values in the same order as header
lines (map (fn[m] (->> m ;; we take m
to-vals ;; extract the values
(clojure.string/join ", "))) coll-of-maps) ;; and join them as strings
header-string (->> header (map name) (clojure.string/join ", "))] ;; header string
(str header-string "\n" (clojure.string/join "\n" lines))))
Hi @andyfry01, @yadolghintev388, and @zeiglerr, welcome to the channel đź‘‹:simple_smile:
Thank you!
Hello.