Fork me on GitHub

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.


Yes! The new update-vals is exactly what I was hoping for.

👍 1

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:

👀 1

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.

👍 1

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 🙂


Yeah, definitely could have used when like this: (when conflicted (pos? conflicted)) which isn't too bad and reads well. The some threaders are a nice way to when your way safely through things that might blow up, which is why I lean on them when I get near a math operation.

👍 1