On Sat, Apr 18, 2009 at 2:52 AM, Michael Hunger <cloj...@jexp.de> wrote:
>
> I tried to use an anonymous function in map but it didn't work.
>
> user=> (map #(%) '(1 2 3))
> java.lang.ClassCastException: java.lang.Integer cannot be cast to 
> clojure.lang.IFn
>
> but with a normal anonymous function it works as expected:

Others have already explained why this happens.

If you really want to do something like that, then you can use "do" to
get rid of the effect of the implicit parentheses:

(map #(do %) '(1 2 3))

Also, since Clojure has first class vectors, you may as well use them
instead of having to quote your literal lists:

(map identity [1 2 3])

[...]
> P.S. As I'm quite fresh to FP and clojure - is there some place where one can 
> show / upload code examples and get some
> hints / help for improving them?

If you don't want to ask here, you could try http://www.lispforum.com/

Although I think there are more Common Lisp people there than Clojure
people, they are quite helpful with newbie Common Lisp questions :)  I
don't think anyone's posted a Clojure code question there yet.

-- 
Michael Wood <esiot...@gmail.com>

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