clojure-nl

Companies working with Clojure in The Netherlands: https://docs.google.com/spreadsheets/d/1NzOqY1v-OReB1IquUgHuT3Kh8K8jhPdlwBM6ds7id6Y/edit?usp=sharing
Mno 2021-02-11T08:02:33.073700Z

Morning! Taking various trains and detours in order to get to zwolle

Mno 2021-02-11T08:03:03.074500Z

At least the snow covered landscapes are pretty

borkdude 2021-02-11T08:49:46.074800Z

@hobosarefriends Whatcha doing in Zwolle?

Mno 2021-02-11T08:50:38.075900Z

The zwolle kvk had available appointments for this month unlike any of the nearer ones

skuro 2021-02-11T09:02:17.076400Z

morning!

skuro 2021-02-11T09:04:13.077900Z

style question: how do you feel about mixing threading macros? e.g.

(-> lots-of-maps
    (->> (filter beautiful-things)
         (sort-by :very-important-key))
    first
    :actual-important-key
    (or meaningful-default))

Mno 2021-02-11T09:04:46.078300Z

I fear them

Mno 2021-02-11T09:05:17.079Z

I feel like my data structure is bad if I have to use them ๐Ÿ˜…

Mno 2021-02-11T09:06:02.079400Z

No concrete reason tho

skuro 2021-02-11T09:07:00.080500Z

I guess you can optimize your data shape for a given need, but in my case the same data is pulled from all sorts of direction so either I create N optimal views or I pull things from an almost always suboptimal shape

Mno 2021-02-11T09:11:04.083800Z

I do like reusing data structures :thinking_face:

Mno 2021-02-11T09:12:40.086Z

In the previous example I would do filtering and sorting before passing it to the threading macro. But that's because of my aforementioned fear.

kirill.salykin 2021-02-11T09:36:39.086500Z

What if you give it a name (in a let block)?

lots-of-maps
    (->> (filter beautiful-things)
         (sort-by :very-important-key))

kirill.salykin 2021-02-11T09:37:09.086900Z

or maybe use this https://clojuredocs.org/clojure.core/as-%3E

kirill.salykin 2021-02-13T15:21:39.109900Z

@skuro ^^^

skuro 2021-02-13T16:32:54.110800Z

Oh sorry url encoding fooled me

kirill.salykin 2021-02-11T09:42:42.087500Z

I would try to avoid them, cause it operates on different contexts in โ€œone placeโ€, -> assumed to be used with assoc data and ->> with collections

2021-02-11T11:26:39.088Z

my vote goes to let

๐Ÿ‘ 1
2021-02-11T11:28:22.089200Z

also I feel like having or in threading macro is a bit confusing to read, maybe (get foo key default) is easier

Mno 2021-02-11T11:40:43.090200Z

Oh boy relevant post in #off-topic, a ->let

borkdude 2021-02-11T11:41:32.090800Z

Now that we're on the topic of threading macros: https://gist.github.com/borkdude/93efc3f5978a2ed545553a47caaf7aa8

Mno 2021-02-11T11:47:06.092600Z

That confuses and scares me

borkdude 2021-02-11T11:47:21.092900Z

Good, because you should just use let ;P

borkdude 2021-02-11T11:47:27.093100Z

"Let over thread"

Mno 2021-02-11T11:48:27.094100Z

My code got called "very idiomatic" at an interview recently ๐Ÿ˜

๐Ÿ‘ 2
Mno 2021-02-11T11:48:33.094400Z

Still riding that high

gklijs 2021-02-11T15:39:18.096200Z

The problem with the treading macro is the map is not always the first one. I was always kind of scared of the ->> but recently used

(->> (into (sorted-map) @transactions-by-iban)
       vals
       (remove empty?)
       (map last)
       vec))
which does itโ€™s thing nicely.