Fork me on GitHub
#beginners
<
2019-06-01
>
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 myCollection.map(f).map(g)

Michael Stokley00:06:06

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

ghadi00:06:36

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

ghadi00:06:15

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

ghadi00:06:34

I've used flip 0 times in about 10 years

ghadi00:06:51

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))
1
clojure-scratch.core> (-> {:a 1} (:a))
1

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

ghadi00:06:21

Macroexpand the forms and compare

ghadi00:06:48

Quote the full expr ' and call macroexpand on it

Michael Stokley00:06:01

ok, thank you! thread-last it is.

ghadi00:06:08

They are equivalent in that particular case

Michael Stokley00:06:23

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

felipebarros06:06:43

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.

felipebarros03:06:31

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.

felipebarros04:06:43

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?

4
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?

gklijs12:06:18

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.

orestis13:06:55

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.

gklijs15:06:02

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