help understanding how map works

2011-09-28 Thread Cluj
I am learning Clojure and have installed Clojure 1.2.0 in an Ubuntu 11
box.

While playing with the map function I ran into some behavior I don't
understand.

I tried to use map to change a list of strings into a list of vectors
of strings, something like:

(A B C) = ( [ A] [B] [C])

Inlining the function does not work:

user= (map #([ % ]) '(A B C))
java.lang.IllegalArgumentException: Wrong number of args (0) passed
to: PersistentVector
user=

But defining an external function does:

user= (defn wrap [ x ] [ x ] )
#'user/wrap
user= (map #(wrap %) '(A B C))
([A] [B] [C])
user=

can someone explain to me why this is the case?

Thanks for your help in advance!


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


Re: help understanding how map works

2011-09-28 Thread Cluj
Thank you! Obvious once someone explains it :)


On Sep 28, 6:13 pm, Mark Engelberg mark.engelb...@gmail.com wrote:
 #([ % ]) is like:
 (defn wrap [ x ] ([ x ]) )

 not
 (defn wrap [ x ] [ x ] )

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