Fork me on GitHub
Michael Stokley00:06:48

it's probably not uncommon to map a collection n times sequentially

Michael Stokley00:06:09

with infix in oo you get something like

Michael Stokley00:06:06

but (-> my-col (map f) (map g)) inserts the collection as the wrong argument to map


Thread last not first

Michael Stokley00:06:32

i have other expressions that only work thread-first

Michael Stokley00:06:50

maybe i should look at compose instead

Michael Stokley00:06:31

i could flip map


No need. Core functions are carefully designed to play properly with thread macros


I've used flip 0 times in about 10 years


flip not existing in the core library is a strong signal

Michael Stokley00:06:00

... why does this work?

clojure-scratch.core> (->> {:a 1} (:a))
clojure-scratch.core> (-> {:a 1} (:a))

Drew Verlee00:06:59

well thats a big question in a way. ->> threads the first value through the other forms (in this case just (: a). And in that case, (:a {:a 1}) works because keywords can act as functions on a map. Does that help?

Drew Verlee00:06:33

in the -> case, it works because maps can act as functions

Michael Stokley17:06:10

thanks @U0DJ4T5U1, that is helpful. i overestimated the difference between thread first and thread last, i think


Macroexpand the forms and compare


Quote the full expr ' and call macroexpand on it

Michael Stokley00:06:01

ok, thank you! thread-last it is.


They are equivalent in that particular case

Michael Stokley00:06:23

i knew about macroexpand but had forgotten i needed to quote the expression


Any tips, articles, videos or books on how to approach studying a new codebase? Is this even a thing people build workflows/systems for?

Drew Verlee00:06:21

not really 🙂. It's such a generic thing that any tool or methodology would probably be worse then staying flexible. Get plenty of sleep! Have open and honest communication with your team about whats going on.


Thank you for your response 🙂 I still have no team (never had one, solo learner) or access to other people programming (besides videos or online live coding) so I often wonder about such stuff that you would just learn by watching a few people with more experience doing.


I have a single programmer friend whom I've never met personally, and he explained to me how he uses grep like tools to regexp search projects and find relevant definitions to keep on grepping and to understand where things are called and why. So for now I have: sleep well, abuse grep and, when possible, communicate honestly with those involved. 🙂 I'm in a point in my personal path that I'm finding these nice places to work and looking at their open source libraries, so I'm doing a lot of reading and sometimes it's tough. When it's Clojure I jump back and forward with cider-find-var and cider-pop-back, highlight stuff in a file with highlight-symbol and search the entire project with Projectile and things are improving. In other languages it's harder. Maybe I need to start looking at the tests first?

Kari Marttila11:06:40

I'm using Cursive as my primary Clojure IDE and I really like it. However I was wondering that should I also be fluent using Emacs / Cider if I have some issues in some production environment (e.g. headless Linux) running Clojure and if I want to start REPL in that box? Or in this kind of situation do Clojurians usually just create a VPN tunnel from their local workstation to the production box and connect their workstation IDE's REPL to the remote nrepl session somehow?


You can also open a REPL from IntelliJ using cursive. Only reason to learn Emacs / Cider I can think of is if the rest of the team is using it.


I just use an SSH tunnel to repl into production.

Kari Marttila13:06:26

Ok. I already thought that the way to go is to setup ssh tunnel to the box and then just connect Cursive repl to it using the tunnel. Thanks.


If you have the matching project checked out you can even get code completion, it's pretty neat.