Lets say I want to use the threading operator to thread a map through a series of function calls. All the functions take the map as a first parameter (good) but one function does not conform to the correct signature (say it takes the map as the last parameter). What is the best way to “fix” the function signature?
Share
The reader macro
#()for anonymus functions is a good candidate here:It is flexible and adds little visual noise. You can of course do many different things, in this case partial function application would also work:
There is also the
->>macro which threads the first expression into the last position. Of course in your use case this doesn’t help much, as you would have to adjust some of the function calls. However if you are chaining many functions that should take the expression as the first argument and then many functions that take the expression as the last argument you could do something likeEDIT: Added extra parenthesis in first example.