PurelyFunctional.tv Newsletter 350: Monoid pattern submissions

Sign up for weekly Clojure tips, software design, and a Clojure coding challenge.

Issue 350 - October 28, 2019 · Archives · Subscribe

On Vacation 🏕

Hello!

This is going to be a light issue this week. I'm on vacation at the moment. I'll miss next week's too!

Conference alert 🚨

I booked my tickets to the 2019 Clojure/conj in Durham, North Carolina this week. If you're going, let me know! I haven't been to a conj in a couple of years and I'm really excited.

I'm also planning on attending a local Elixir conference (The Big Elixir) if you happen to be going to that. In that case, give me a holler!

Currently recording 🎥

Property-Based Testing with test.check is now split into three courses, Beginning, Intermediate, and Advanced. The launch begins when I come back from vacation. Stay tuned.

Clojure Challenge 🤔

Last week's challenge

The challenge in Issue 349 was to write a function to build monoid-pattern compliant functions.

You can check out the submissions here.

My favorites were the incredibly succinct from Ben Grabow:

(defn monoid [id fn-2]
  (fn [& args]
    (reduce fn-2 id args)))

and the incredibly clear and optimized from Teodor Heggelund:

(defn monoid [id fn-2]
  (fn
    ([] id)
    ([x] x)
    ([x y] (fn-2 x y))
    ([x y & more]
     (reduce fn-2 (fn-2 x y) more))))

No challenge this week.

Rock on!
Eric Normand