Fast Function Currying in Clojure (Without Macros)

submited by
Style Pass
2021-07-05 16:00:06

These books fund my work! Please check them out.

Yet another version of Fluokitten (), a library that enables "monadic" programming in Clojure, has been released. The highlight of the release is a vastly improved function currying performance. Now, curried functions have the same performance as the ordinary, uncurried ones! Here's a short introduction, demo, and a bit of benchmarking to convince you that you can use this partial on steroids without worrying about the performance overhead.

There are much more cool functions there - be sure to check documentation and articles at Flukitten's website, and this blog.

The closest thing to currying in Clojure is the partial function. It is so similar on the surface that, when the topic comes up in online discussions, the answer is usually that Clojure supports currying, and you can do this using partial.

The idea of both currying and partial is that when you apply a function with fewer arguments than it requires, instead of throwing an error, the function closes over what's there and creates a new function that awaits for the remaining arguments. The main difference is that partial is a higher order function that has to be called explicitly, while currying is automatic.

Leave a Comment