Re: help understanding how map works

2011-09-28 Thread Sean Corfield
On Wed, Sep 28, 2011 at 6:32 PM, Cluj  wrote:
> Thank you! Obvious once someone explains it :)

You could also do: (map vector '("A" "B" "C"))
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

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


Re: help understanding how map works

2011-09-28 Thread Mark Engelberg
#([ % ]) 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

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