In Clojure macros are executed before code is evaluated. Macros allow us to manipulate the program being compiled. There are two macros in particular that I like to demonstrate why this is useful:
- Thread First
->
- Thread Last
->>
Note: in Clojure sequence data structures (lists & vectors) are usually the last item in an argument list; where as map data structures are usually the first argument in an argument list
Our original program requires us to effectively read it "inside out":