On Thu, Mar 25, 2010 at 6:52 PM, WoodHacker <ramsa...@comcast.net> wrote: > I thank all the people who have sent me solutions to my Conj > problem. Unfortunately, none of them seem to work. > > The issue is adding a value to a defined vector - (def savedColors > [black, white]) > > One solution was given as: (swap! savedColors conj newcolor) > > This produces still the following runtime error: > > Exception in thread "AWT-EventQueue-0" > java.lang.ClassCastException: clojure.lang.PersistentVector cannot > be cast to clojure.lang.Atom > > Another solution was to make savedColors an atom - (def savedColors > (atom [black, white])) > > This produces a new compile error: > > Exception in thread "AWT-EventQueue-0" > java.lang.IllegalArgumentException: Don't know how to create ISeq > from: clojure.lang.Atom
The def cannot produce that error. You probably mean that it originates with some reference to savedColors that is expecting a sequence. You must explicitly dereference savedColors by prefixing it with @ to get at the contained value: user> (def saved-colors (atom [1, 2])) #'user/saved-colors user> (doseq [x @saved-colors] (println "Saved color:" x)) Saved color: 1 Saved color: 2 nil -Per -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.