the-frey~/blog

Clojure reducers

Some very quick notes

23 January 2018

I’ve been throwing together some notes on functional programming in Clojure for a small presentation at work, and I thought it would be useful to show how even in a contrived, noddy example it was simple to bring reducers - and thus improved performance - into the picture.

Bringing in reducers is simple:

Then switching out (into []) for foldcat is trivial:

Finally, you can see how we could then look up the member associated with the transaction:

This is a very contrived code example, and probably needs a refactor, but you get the idea.

Update: when I presented this, it occurred to me that I’d been a naughty boy by not parameterizing the inputs to the function, so:

Fork me on GitHub