On Wednesday, November 2, 2011 11:37:32 AM UTC+2, HamsterofDeath wrote:
>
> hi there,
>
> i stumbled over two odd things
> 1) -> and ->> have the same source code. why is that?
>
Similar, but not the same [1]:
(~(first form) ~x ~@(next form)) vs. (~(first form) ~@(next form) ~x)
 

> 2) why can't i use "(-> "hi" #(println %))" directly? why do i have to
> put my function into a symbol first? is there a way to avoid this?
>
#(println %) expands to (fn [%] (println %)) so (-> "hi" #(println %)) 
expands to (fn "hi" [%] (println %)). 

Note also that (-> "hi" println) would work since it's transformed into 
(println "hi"). Also, the form (-> "hi" (#(println %))) should also work 
fine.

/jonas

[1] 
https://github.com/clojure/clojure/blob/f5f827ac9fbb87e770d25007472504403ed3d7a6/src/clj/clojure/core.clj#L1528
 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to