Thanks for the support and especially the examples.  I will be back when I 
bump into the next level of complexity ;-)

On Monday, 24 September 2012 12:04:42 UTC+2, Mond Ray wrote:
>
> I am playing around with maps and using wish lists as a learning tool. I 
> have a list of items in wish lists like this:
>
> user=> items
> [{:name "Item 1", :cost 20.0} {:name "Item 2", :cost 40.0}]
>
> user=> wiggle-items
> [{:name "Wiggle 1", :cost 20.0} {:name "Wiggle 2", :cost 40.0} [:name 
> "Item 3" :cost 10.0]]
>
> user=> (def wish-lists [
> {:name "WL1" :items items}
> {:name "WL2" :items wiggle-items}
> ]
> )
> #'user/wish-lists
>
> user=> wish-lists
> [{:name "WL1", :items [{:name "Item 1", :cost 20.0} {:name "Item 2", :cost 
> 40.0}]} {:name "WL2", :items [{:name "Wiggle 1", :cost 20.0} {:name "Wiggle 
> 2", :cost 40.0} [:name "Item 3" :cost 10.0]]}]
>
> -------
>
> I now want to add an item to one of the Wish Lists but am struggling with 
> assoc and assoc-in (which seems to be the one I need).
>
> -------
>
> user=> (def new-wi (conj wiggle-items [ :name "Item 3" :cost 10.0 ]))
>
> #'user/new-wi
>
> user=> (assoc-in wish-lists [:name "WL1"] [:name "WL1" :items new-wi])
> IllegalArgumentException Key must be integer 
> clojure.lang.APersistentVector.assoc (APersistentVector.java:312)
>
>
> As you can see the REPL gives me an error stating that the keys must be 
> Integers. Is that right?  Or is my call process faulty?
>
> Thanks in advance for your support.
>
>
> ray
>

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

Reply via email to