If I have this:
(defstruct thing
(part1 0)
(part2 0))
Is there a way to specify a function that can be used
as a compare function - and have it get picked up by
equal or eql?
For example how would I create a hash
table and use a structure as a key? In this case I
would like any two thing-p objects to be equal if
their part1 and part2 slots are equal.
Or would I need to create my own hash table to do that?
-Ram
Ram Bhamidipaty <·······@gmail.com> writes:
> If I have this:
>
> (defstruct thing
> (part1 0)
> (part2 0))
>
> Is there a way to specify a function that can be used
> as a compare function - and have it get picked up by
> equal or eql?
Do you really need EQUAL or EQL?
EQUALP works recursively on structures.
> For example how would I create a hash
> table and use a structure as a key? In this case I
> would like any two thing-p objects to be equal if
> their part1 and part2 slots are equal.
What about EQUALP?
> Or would I need to create my own hash table to do that?
On some implementation (such as clisp), as an extension, you may use
your own equal function with hash-table.
--
__Pascal Bourguignon__ http://www.informatimago.com/
THIS IS A 100% MATTER PRODUCT: In the unlikely event that this
merchandise should contact antimatter in any form, a catastrophic
explosion will result.
On Sep 23, 10:28 pm, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> Ram Bhamidipaty <·······@gmail.com> writes:
> > If I have this:
>
> > (defstruct thing
> > (part1 0)
> > (part2 0))
>
> > Is there a way to specify a function that can be used
> > as a compare function - and have it get picked up by
> > equal or eql?
>
> Do you really need EQUAL or EQL?
> EQUALP works recursively on structures.
>
> > For example how would I create a hash
> > table and use a structure as a key? In this case I
> > would like any two thing-p objects to be equal if
> > their part1 and part2 slots are equal.
>
> What about EQUALP?
>
> > Or would I need to create my own hash table to do that?
>
> On some implementation (such as clisp), as an extension, you may use
> your own equal function with hash-table.
>
Thank you! I did not now about equalp. This works for me.
-Ram