This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-26
Channels
- # announcements (6)
- # babashka (29)
- # babashka-sci-dev (2)
- # beginners (129)
- # calva (9)
- # clara (16)
- # cljdoc (49)
- # clojure (125)
- # clojure-bay-area (3)
- # clojure-europe (55)
- # clojure-france (1)
- # clojuredesign-podcast (8)
- # clojurescript (85)
- # conjure (3)
- # core-logic (2)
- # cursive (1)
- # events (1)
- # honeysql (61)
- # jobs-discuss (23)
- # lsp (69)
- # malli (14)
- # nrepl (3)
- # off-topic (16)
- # portal (11)
- # re-frame (8)
- # releases (1)
- # ring (2)
- # shadow-cljs (12)
- # vim (42)
- # xtdb (18)
In episode 76, you talk about juxt
and “the obvious missing function in core” map-vals
. Isn’t that what the new core functions update-vals
and update-keys
do? The ones that got introduced with Clojure 1.11.0. I haven’t looked, but maybe those use juxt
under the hood. Edit: I checked the implementations. They use reduce-kv
, not juxt
.
I think the juxt implementation that I used before is nice to look at, but not at the performance level to be included in core.
I liked this comment by fogus about what went into the implementation of update-vals
and update-keys
and why the approach was different: https://www.reddit.com/r/Clojure/comments/tk6og2/clojure_111_is_now_available/i1rnqp4/
Having listened to episode 77 (about some->
) would have helped me when I encountered this problem 😊
Oh yeah! I love the some threaders. I just had some code recently where I wanted to check if a (potentially nil) variable was greater than zero and I had this, because pos?
is not nil-safe:
(and conflicted (pos? conflicted))
And I realized that I could do this instead:
(some-> conflicted pos?)
I think that reads nicely. Oh, cool! I was not aware of the pos?
function. At first, I read it as “position?” which didn’t make sense. I would have naively checked if the integer was greater than 0
or something like that. Wouldn’t it be possible to use when
as well, instead of and
or some->
? Side-note: As a non-native English speaker, I often get the terms where, when and while mixed up in my mind. For example, when using for
, there is both :when
and :while
, which is a bit confusing to me. It was comforting to hear your guys say how you also get them mixed up sometimes 🙂