Hi Brian,

(1) What does it mean to be equal on id and not equal on the other  
fields? If two fields claim the same id but a different name, how  
would you know which one to keep?

(2) Given some answer to #1, why not store the structs in a map under  
id?

(3) For the geocoded place struct, I would be tempted to just create a  
separate defstruct. Nothing in Clojure prevents the two different  
kinds of structures from being substituted for one another. You could  
look into make-hierarchy, etc. plus defmulti if you find that you need  
inheritance-like behavior for method dispatch.

Stuart

> I'm attempting to learn Clojure with a long history of OO and have  
> some
> questions.    I've created a defstruct for a place type object like:
>
> (defstruct place :id :name :street :city :state :zip)
>
> I want to write a function that would take a list of places and remove
> the duplicates.   Duplicates are defined by places having the  
> same :id.
> I created a 'place' namespace and attempted to create a function
> called '=' that would only use the :id to compare two places, however,
> I was not about to create such a function name.   Is there a preferred
> function name for equality in this case?
>
> Coming from an OO background and wanting a geocoded-place
> struc is there a way to "inherit" from the place struct?   Something
> like take all of the existing keys from the place struct and also add
> :latitude & :longitude?
>
> Thanks.
>
>
>
>
>
> >


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

Reply via email to