calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
bringe 2021-01-05T00:25:48.165300Z

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

🎉 4
roelof 2021-01-05T13:45:48.166800Z

How can I step by step through a code to see what I really does ?

pez 2021-01-05T13:49:30.167200Z

You mean like in a debugger?

roelof 2021-01-05T13:50:13.167400Z

I think so

roelof 2021-01-05T14:05:13.167800Z

or did I type the break on the wrong place

roelof 2021-01-05T14:05:18.168100Z

(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)) 

roelof 2021-01-05T14:05:53.168800Z

as soon as I choose to got in the code It seems that the debugging stops

pez 2021-01-05T14:15:12.172500Z

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.

Jakub HolĂ˝ 2021-01-05T14:15:34.172900Z

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!

pez 2021-01-05T14:18:33.174200Z

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.

đź‘Ť 1
roelof 2021-01-05T14:18:52.174600Z

@pez oke back to the docs how to do that

pez 2021-01-05T14:19:47.175Z

It’s this one: https://calva.io/debugger/#instrumenting-a-function

pez 2021-01-05T14:22:39.177100Z

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.

đź‘Ť 1
roelof 2021-01-05T14:22:53.177400Z

hmm, wierd, I do `crtl+alt+c and then i but no breaks

pez 2021-01-05T14:24:10.178Z

That should instrument the function. So that when you run it, it should break. Doesn’t happen?

roelof 2021-01-05T14:27:04.178200Z

first not

roelof 2021-01-05T14:27:32.178900Z

but when I did `crtl+alt+c and then holding the crtl-alt keys it worked

roelof 2021-01-05T14:27:42.179200Z

nice to see how things are working

pez 2021-01-05T14:30:06.179600Z

About that def technique: https://clojureverse.org/t/exploring-using-def-x-x/3946

roelof 2021-01-05T14:35:08.179900Z

thanks,

roelof 2021-01-05T14:35:36.180600Z

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))))  

bringe 2021-01-05T23:04:32.182600Z

Hi @andyfry01, @yadolghintev388, and @zeiglerr, welcome to the channel đź‘‹:simple_smile:

2021-01-05T23:04:58.182900Z

Thank you!

2021-01-05T23:06:37.183100Z

Hello.