Morning! Taking various trains and detours in order to get to zwolle
At least the snow covered landscapes are pretty
@hobosarefriends Whatcha doing in Zwolle?
The zwolle kvk had available appointments for this month unlike any of the nearer ones
morning!
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))
I fear them
I feel like my data structure is bad if I have to use them ๐
No concrete reason tho
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
I do like reusing data structures :thinking_face:
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.
What if you give it a name (in a let block)?
lots-of-maps
(->> (filter beautiful-things)
(sort-by :very-important-key))
or maybe use this https://clojuredocs.org/clojure.core/as-%3E
@skuro ^^^
Oh sorry url encoding fooled me
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
my vote goes to let
also I feel like having or
in threading macro is a bit confusing to read, maybe (get foo key default)
is easier
Oh boy relevant post in #off-topic, a ->let
Now that we're on the topic of threading macros: https://gist.github.com/borkdude/93efc3f5978a2ed545553a47caaf7aa8
That confuses and scares me
Good, because you should just use let ;P
"Let over thread"
My code got called "very idiomatic" at an interview recently ๐
Still riding that high
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.