Hi,

I am new to clojure and I am very excited about learning the
language.  I have a question about replacing an element in a list.   I
have elements that look like this :

{:id G__781, :value 1}

The list looks like this:

({:id G__821, :value 1} {:id G__820, :value 1} {:id G__819, :value 1}
{:id G__818, :value 1} {:id G__817, :value 1})

I want to update an element in the list by conjoining a new list with
an updated element.  For example, I'll update the head of the list:
({:id G__821, :value 10} {:id G__820, :value 1} {:id G__819, :value 1}
{:id G__818, :value 1} {:id G__817, :value 1})

My update code (it really builds a new list with and replaces the
updated element) looks like this:

(defn update-id-list [id-list new-id new-id-list]
  (doseq[old-id id-list
         new-id-list (conj new-id-list (choose-id old-id new-id) )]
    (println "New List " new-id-list)) new-id-list)

(defn choose-id[old-id new-id]
  (if (= (:id old-id) (:id new-id)) new-id old-id))

This doesn't work.  It never conjoin's elements and ultimately returns
an empty list.  I've tried using various other methods but I keep
going in circles.

Any ideas why this wouldn't work?

Thanks,
James

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