Threading Macros

Learn to transform Clojure code into a more readable structure that follows a sequential order.

Threading macros

Threading macros is a functionality available in the Clojure core library that’s also a macro, such as the when macro. Threading converts nested function calls into a linear flow, improving readability and enabling us to visualize and easily understand how the data is flowing from one call to the other. They’re widely used and also known as the Clojure arrows. The functionality aligns with the way our brains think about and understand a process or a dataflow.

Press + to interact
Illustrative representation of threading macros
Illustrative representation of threading macros

There are two types of threading macros:

  • Threading first: This is represented by ->.

  • Threading last: This is represented by ->>.

Threading is an innovation to the Lisp dialect brought by Clojure. It supports a functional style of programming with return values and makes composition intuitive, leading to ...

Access this course and 1400+ top-rated courses and projects.