(defn create-key-value [value]
(when (some-condition-true) {:extra-key "extra-value"))
(defn create-map []
{:foo "a"
:bar "b"})
{:foo "a", :bar "b", :extra-key "extra-value"}
{:foo "a", :bar "b"}
(defn create-key-value [value]
(when (some-condition-true) {:extra-key value))
(defn create-map []
(let [my-map {:foo "a" :bar "b"}]
(merge my-map (create-key-value "some-value")))
(defn create-map []
(merge {:foo "a"
:bar "b"
... many more keys}
(when (some-condition-true)
{:extra-key value)))
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
(defn create-map []
(cond-> {:base :map}
(pred1) (assoc :extra-key1 value)
(pred2) (assoc :extra-key2 value)
(pred3) (assoc :extra-key3 value)
(pred4) (assoc :extra-key4 value)))
A function could be appropriate, but a macro not appropriate, since everything you need here can be done with using macros.