janus a écrit :
> It can't figure out why this is not working or was I sleeping while
> trying it out.
>
> (apply #(println %) [2 3])
>   
This line is equivalent to (#(println %) 2 3) which errors since 
#(println %) takes only one argument.
user=> (macroexpand '#(println %))
(fn* [p1__3493] (println p1__3493))

Depending on what you were trying to achieve, you could have written:
(apply println [2 3]) ; same as (println 2 3)
(apply #(println %) [2 3] nil) ; same as (#(println %) [2 3]) or 
(println [2 3])
(map #(println %) [2 3]) ; roughly equivalent to  [(#(println %) 2) 
(#(println %) 3)] or [(println 2) (println 3)]
(map println [2 3]) ; roughly equivalent to  [(println 2) (println 3)]
(doseq [i [2 3]] (print i)) ; same as (do (println 2) (println 3))

> And, why is it that I can't do this?
>
> Instead of (let [{coin :coin :as snake}{...................}][coin
> snake])
> I tried this (let [{:coin coin :as snake}{...................}][coin
> snake]) and got failure. Why is it so?(just changed the position of
> the key :coin)
>   
See http://clojure.org/special_forms#toc4 "Map binding-forms [...] 
consists of a map of binding-form-key pairs."
coin :coin is a binding-form-key pair while :coin coin is 
key-binding-form pair.
Some pairs start with a keyword (:as, :or, :keys, :strs and :syms) but 
they have a special meaning.

Hope this helps.

Christophe

--~--~---------~--~----~------------~-------~--~----~
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
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