"12" Thanks to (partial) I can turn it into (...">

Clojure Partial Law

I have the following function

(defn fun [ab] (str ab)) (fun "1" "2") ;; --> "12" 

Thanks to (partial) I can turn it into (fun b) and have fixed a

 (def fun2 (partial fun "1")) (fun2 "2") ;; --> "12" 

Does clojure have something like (partial-right) or a way to reorder the arguments of a function so that instead of a fixed a I can have a fixed b and therefore have a function (fun a) ?

thanks

+6
source share
2 answers
 (defn partial-right [f & args1] (fn [& args2] (apply f (concat args2 args1)))) 

But ask yourself ... why is this no longer part of the standard library? Maybe other people wandered in this way, and it turned out badly?

+3
source

In your specific example, you can go with variety:

 (defn fun ([ab] (str ab)) ([a] (str a "1"))) 
0
source

All Articles