On Mar 29, 1:26 am, strattonbrazil <[email protected]> wrote:
> Is this the common way to do it?
>
> (def sister (assoc brother :name "Cindy"))
>
Please note that actually def'ing each value is not what you're
supposed to do :) def is reserved for global constants and dynamically
rebindable variables, and redefing an existing variable is considered
bad style.
You might do something like this:
(defn children [father mother & children]
(let [base {:father father :mother mother}]
(for [c children] (assoc base :name c))))
;; note, that's not a for loop, but a seq comprehension
which, when called like
(children "John" "Mary" "Cindy" "Gary")
produces a (lazy) sequence of maps representing the children.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
To unsubscribe from this group, send email to
clojure+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.