Fork me on GitHub
#beginners
<
2019-12-04
>
mloughlin14:12:36

is there a way to comp the same function n times?

lispyclouds14:12:12

((apply comp (repeat 5 inc)) 1) => 6

andy.fingerhut14:12:17

Maybe something like this?

user=> ((apply comp (repeat 5 inc)) 1)
6

lispyclouds14:12:40

read my mind!

andy.fingerhut14:12:43

Wow, that seems creepy 🙂

mloughlin14:12:44

thanks, I initially bodged together a macro but I like the comp way better

mloughlin14:12:19

all the macro did was loop and spit out the nested s-expr

Meepu15:12:18

Do you have any recommendations on tutorials on how to debug Clojure? I've tried VSCode with Calva and Cursive, but I just can't figure out how they should be used when developing a non-trivial project. I can evaluate some simple expressions, but when I bring in a real project with multiple files and databases, I don't know where to start.

enforser15:12:29

https://www.youtube.com/watch?v=FihU5JxmnBg&amp;t=1s Was sent this by a coworker the week before I started my first Clojure job!

👍 4
Meepu15:12:56

Thanks, I'll take a look. 🙂

pez15:12:31

That should work well using Calva. Just sayn' 😃

Meepu15:12:17

Interesting, but very general. I need to learn more about the tooling before I can benefit from that. At the moment I can't even evaluate my code in REPL unless it's a very trivial one file program.

seancorfield17:12:14

@ULGNZ8B9S This might help you more https://binged.it/2LoXZvN (it's another talk by Stu)

seancorfield17:12:59

There's also this one on REPL-Driven Development by Stu https://vimeo.com/223309989

Meepu17:12:05

Thanks, I'll check them out!

seancorfield17:12:01

Getting that basic tight feedback loop with evaluating code from your editor -- and not typing into the REPL itself! -- is key to getting going with Clojure and, in particular, debugging code that doesn't work.

Meepu17:12:30

Definitely! :)

sjharms22:12:25

Why does the first one set data to nil, and the second one work?

(def data (-> "output.json"
               slurp
               json/read-str :key-fn keyword))

(def data (json/read-str (slurp "output.json") :key-fn keyword))

noisesmith22:12:33

because :key-fn and keyword are not provided as args to read-str in the first one

noisesmith22:12:42

they are called as functions on the result of read-str

thanks 4
noisesmith22:12:51

clojure is not white-space aware

seancorfield22:12:16

(def data (keyword (:key-fn (json/read-str (slurp "output.json"))))) is what the first expression macroexpands to...

sjharms22:12:33

I should have wrapped it up in parens, and then it would get called as the first argument

jaihindhreddy13:12:43

You can use macroexpand-1 and macroexpand to understand what macros do. Also, use read-string when you encounter some reader syntax you don't understand. For example 'a is just syntax sugar for (quote a). You can discover that by just running (read-string "'a").