Advent 2019 part 3, `every-pred` and `some-fn`
DRANK

This post is part of Advent of Parens 2019, my attempt to publish one blog post a day during the 24 days of the advent.Ah clojure.core, it’s like an all you can eat hot-pot. Just when you think you’ve scooped up all it has to offer, you discover another small but delicious delicacy floating in the spicy broth.In exactly the same way I recently became aware of two functions that until now had only existed on the periphery of my awareness. I’ve since enjoyed using them on several occasions, and keep finding uses for them.These are every-pred, and some-fn. I’ll demonstrate them with an example. Say you have a discussion forum. People can be admins or moderators, and besides their username they can optionally set a nickname.(def people [{:name "Elsie" :admin? true :mod? true} {:name "Lin Shiwen" :nickname "Rocky" :mod? true}]) If you want to grab people’s nickname if they have one, or fall back to their …

lambdaisland.com
Related Topics: