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 lik
On 24.09.2012 13:04, Mond Ray wrote:
> 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]]}]
> user=> (assoc-in wish-lists [:name
(defn new-item-ks [wlists wlist-name]
(first
(keep-indexed #(when (= (:name %2) wlist-name)
[%1 :items (count (:items %2))])
wlists)))
(assoc-in wish-lists (new-item-ks wish-lists "WL2")
{:name "Item 3" :cost 10.0})
On Monday, September 24, 201
On Monday, September 24, 2012 3:04:42 AM UTC-7, Mond Ray wrote:
>
>
> 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?
>
>
I think the problem is that wish-lists is a vector, so you need a key for
the vector first
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" :cos