I have a function that generatwed unique ID's, something like this:

  (def k (atom 0))
  (defn generate-id [] (swap! k inc))

 and I try to use it like this:

   {(generate-id) "foo"
    (generate-id) "bar"}

How ever, I get

   IllegalArgumentException Duplicate key: (generate-id)  
clojure.lang.PersistentArrayMap.createWithCheck (PersistentArrayMap.java:70)

This works as expected.

  (let [id1 (generate-id)
        id2 (generate-id)]
    {id1 "foo" id2 "bar})

Should I be able to call generate-id in map literal?

-- 
-jarppe

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