(partial apply str) and apply-str in clojure's ->

Posted by Jason Baker on Stack Overflow See other posts from Stack Overflow or by Jason Baker
Published on 2010-04-05T01:45:50Z Indexed on 2010/04/05 1:53 UTC
Read the original article Hit count: 423

Filed under:
|
|

If I do the following:

user=> (-> ["1" "2"] (partial apply str)) 
#<core$partial__5034$fn__5040 clojure.core$partial__5034$fn__5040@d4dd758>

...I get a partial function back. However, if I bind it to a variable:

user=> (def apply-str (partial apply str))
#'user/apply-str
user=> (-> ["1" "2" "3"] apply-str)       
"123"

...the code works as I intended it. I would assume that they are the same thing, but apparently that isn't the case. Can someone explain why this is to me?

© Stack Overflow or respective owner

Related posts about clojure

Related posts about partial