I did a poor job explaining myself.  Sorry.  I understand that copying
an immutable structure is worthless.  I want a copy of a structure
except one or two specific properties.  For example,

(defstruct person :name :address :mother :father)
(def brother (struct person "Gary" ...))

(def sister (struct person "Cindy" (:address brother) (:mother
brother) (:father brother))) ; same attributes as brother except name
is different

Is there a shorter way to do this?

While I'm on the subject, what is the difference between a structure
and a hash?  Are there performance implications?  Why wouldn't I just
use a hash if structs can hold new values anyway?  When should I use
one over the other?

On Mar 28, 11:52 am, B Smith-Mannschott <bsmith.o...@gmail.com> wrote:
> On Sun, Mar 28, 2010 at 18:29, strattonbrazil <strattonbra...@gmail.com> 
> wrote:
> > This may be really basic.  So much so that it's hard to find on the
> > internet, but is there something like a copy constructor in clojure,
>
> A copy-constructor is redundant in a language where values are
> immutable. (Just refer to it since it can never change).
>
> > where I can copy everything in a structure except one or two keys?
>
> Something like this?
>
> (select-keys map keyseq)
> Returns a map containing only those entries in map whose key is in keys
>
> > Maybe something like struct-map, but fills in the other variables not
> > supplied by another data structure.
>
> ?
>
> (def another-datastructure {:a 1 :b 2})
> (def my-datastructure (assoc another-datastructure :c 3 :d 4))
>
> // Ben

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

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to