Morning
Good morning!
morning
Hallo
Here's twisting you a good morning
morning!
morning
moin moin
morning
omg, I hate the packaging in R
Been ages since I even looked at R packaging.
does everyone here use rich comment blocks? https://betweentwoparens.com/rich-comment-blocks
(I love them and use them loads)
I use rich comments loads though Iβm fairly sure thatβs down to pairing with you for so long @otfrom
I started using them some weeks ago. A commenter on my Twitch streams was very persistent and pushed me to it. Very thankful about that!
They are handy to have test script expressions in for the REPL.
yes, I do use them, typically at the end of a file. at work we prepend it with ;;;; scratch
clj-kondo also lints them by default, as if they are part of your normal code
Clojure footgun of the week: https://twitter.com/borkdude/status/1314191092607324160
This is one of those "where FP meets the real world" things, where you need to look under the hood to see how things are implemented. Monoids... but please check the source.
are you saying this is junk
http://clojure.github.io/core.cache/#clojure.core.cache/ttl-cache-factory
no, I'm referring to the built-in one
So, when you see if
do you think control-flow or expression?
it's slightly annoying that they all circle around the same f'ing name
@slipset that's a trick question. the only control flow in Clojure is throwing exceptions
π
Ok, so the thing is that years of java-damage leads me to write code like
(if foo
(side-effecting-fn! lol)
(side-effecting-fn! sob))
rather than
(side-effecting-fn! (if (foo lol sob)))
In the first case I use if
for control-flow, in the second I use it as an expression.
Honestly, I think both are fine, in different modes of thinking. Sometimes you're writing a script or task which imperatively does things, at other times you're just building up values.
oh, the damage I've done to you, you poor thing
I find that the latter helps me move difficult code away from the sideffecting code which then makes the difficult code easier to test
yeah, almost all of my refactoring is separating side effecting code from pure
@slipset This is what your talk on ClojureD was also about right
one of several of these
Mostly, yes
I guess I didn't pick up this example specifically.
Speaking of which. ClojureD was so important for me, knowing how this year turned out.
Likewise, I'm thankful I could be there
It ended up being this years only conference, and it helped me get on the defn-podcast, which I must say, the recording Saturday-night was one of the best Saturdays this year.
And ClojureD showed how important the community is to me, and and how valuable I think it is to meet you guys IRL.
I guess we're closing in on Thanksgiving π
π» cheers to that
@borkdude thx to clj-kondo I can't look at https://clojurians.slack.com/archives/CBJ5CGE0G/p1602166804278100 w/o thinking that it should be a when
unless it was
(side-effecting-fn! (if foo lol sob))
Hmmm... Hailing in Dundee
why would I want to use mapv
rather than (into []...)
?
@otfrom looking at the source, mapv
is implemented using (into [] (map f ...))
hmm, only when using multiple colls
I think it comes down to pretty much the same thing
except when using mapv, you won't create that much garbage (compared to using a lazy seq as the last arg of into)
do you get an extra lazy seq if your map transducer is doing the work of the f in your mapv?
no
(mapv do-my-funky-think my-seq)
vs
(into []
(map do-my-funky-think)
my-seq)
(into [] (map f) coll)
is probably the same-ish as
(mapv f coll)
so, just a matter of taste then?
you could try to do some informal perf tests, I expect not to see a difference
there is always my law (can I say that?) of "you are gonna need to comp in something else eventually"
YAGNTCINSEE
you can also use eductions in that case
π
I admit that I struggle a bit with when to use eductions
I'm pretty comfortable with transduce and into
eductions just couple the transformations with an input source
but cat, eductions and sequence are things I reach for only occastionally
and you can do other xforms on top of those
before realizing it into a target
not entirely sure I follow how that would be used. Have you got an example you can point me at?
(def src [1 2 3])
(def ed (eduction (map inc) src))
(def ed2 (eduction (map inc) ed))
(into [] ed2) ;; => [3 4 5]
in our app we have a SqlReducible, so in the example the src would be a result set from a database
we can then do some transformations on that, and then read out the result later
this allows you to just pass the thing around, while not having one giant transducer
ah, I think I know a place in my code where I can use that
thx @borkdude!
atm, I've got a function that returns a transducer where you pass in some early steps to do the client specific things before you get to the standard flow
https://github.com/MastodonC/witan.cic.driver/blob/master/src/witan/cic/episodes.clj#L819-L864