Hi Roelof,

Just a general advice, for figuring out how small things like these work 
and why they don't work I find Lighttable (http://lighttable.com/) an 
awesome IDE. This is the best thing available to learn clojure (combined 
with a good book or online resource of course) and I would have to have 
IDEs with an instant inline REPL for different languages too while learning 
these.

However, what I usually did (and still sometimes do) is fire up Lighttable, 
open a barebone namespace, insert this function:

(defn add-author [book new-author]
  (assoc book (conj :authors new-author)))
and

(add-author little-schemer {:name "Gerald J. Sussman"})

then evaluate both and just see what happens. Most of the times something 
failed and then it's easy to take one step back and just evaluate simpler 
things like:
(conj :authors {:name "Gerald J. Sussman"}) 
or whatever the smallest example might be. This helps tremendously in learning 
and understanding what works and what doesn't work.

Disclaimer: This post is not here to say: RTFM and stop posting questions, but 
it is here to show you a better way learning a language.
So I hope you don't get me wrong and enjoy the funny clojure ride.

Best Regards,
Sven



Am Mittwoch, 29. Oktober 2014 12:01:18 UTC+1 schrieb Roelof Wobben:
>
> Hello, 
>
> For a exercise I have to add something to the end of a existing map. 
>
> So I thought this would work : 
>
> (defn add-author [book new-author]
>   (assoc book (conj :authors new-author)))
>
> and call the function with : 
>
> (add-author little-schemer {:name "Gerald J. Sussman"})
>
>
> then I see this error message : 
>
>
> ClassCastException clojure.lang.Keyword cannot be cast to 
> clojure.lang.IPersistentCollection  clojure.core/conj (core.clj:83) 
>
>
> Roelof
>
>
>
>
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to