Fork me on GitHub
#clojure-nl
<
2021-02-11
>
Mno08:02:33

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

Mno08:02:03

At least the snow covered landscapes are pretty

borkdude08:02:46

@hobosarefriends Whatcha doing in Zwolle?

Mno08:02:38

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

skuro09:02:13

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

kirill.salykin09:02:42

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

Mno09:02:46

I fear them

Mno09:02:17

I feel like my data structure is bad if I have to use them 😅

Mno09:02:02

No concrete reason tho

skuro09:02:00

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

Mno09:02:04

I do like reusing data structures :thinking_face:

Mno09:02:40

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.salykin09:02:39

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

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

skuro16:02:54

Oh sorry url encoding fooled me

Dmytro Bunin11:02:39

my vote goes to let

👍 4
Dmytro Bunin11:02:22

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

Mno11:02:43

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

Mno11:02:06

That confuses and scares me

borkdude11:02:21

Good, because you should just use let ;P

borkdude11:02:27

"Let over thread"

Mno11:02:27

My code got called "very idiomatic" at an interview recently 😏

👍 8
Mno11:02:33

Still riding that high

gklijs15:02:18

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.