A strange request: I'd like a data structure that listp returns NIL
for, that I can use as a hash table key and that I can pack a few
unbounded integers into.
Simple vectors would be the obvious choice, but even with equal hash
tables, unfortunately (equal (vector 1 2 3) (vector 1 2 3) returns
NIL.
Does anyone know of anything that Lisp naturally offers that would
satisfy my request? Otherwise I could do something nasty like storing
the numbers in a string like "(1 2 3)" and using read-from-string, but
I'm certainly open to other suggestions.
-- Mark
·······@cis.ohio-state.edu (mark carroll) writes:
> A strange request: I'd like a data structure that listp returns NIL
> for, that I can use as a hash table key and that I can pack a few
> unbounded integers into.
>
> Simple vectors would be the obvious choice, but even with equal hash
> tables, unfortunately (equal (vector 1 2 3) (vector 1 2 3) returns
> NIL.
>
> Does anyone know of anything that Lisp naturally offers that would
> satisfy my request? Otherwise I could do something nasty like storing
> the numbers in a string like "(1 2 3)" and using read-from-string, but
> I'm certainly open to other suggestions.
>
> -- Mark
As long as you don't plan to change the vector keys after you start
using them, you can use an equalp hash-table. Beware, though; if
you change the innards of the vectors, you will "lose" hash-table
entries. Of course, this is also true for list keys on equal
hash-tables, so I assume that you will be ok if you are careful.
--
Duane Rettig Franz Inc. http://www.franz.com/ (www)
1995 University Ave Suite 275 Berkeley, CA 94704
Phone: (510) 548-3600; FAX: (510) 548-8253 ·····@Franz.COM (internet)
·······@cis.ohio-state.edu (mark carroll) writes:
>I'd like a data structure that listp returns NIL for,
>that I can use as a hash table key and that I can pack
>a few unbounded integers into. Simple vectors would be
>the obvious choice, but even with equal hash tables,
>unfortunately (equal (vector 1 2 3) (vector 1 2 3) returns NIL.
Use an equalp hash table.
(equalp (vector 1 2 3) (vector 1 2 3)) => T
Will Mengarini <······@eskimo.com>
Free software: the Source will be with you, always.
In article <············@eskinews.eskimo.com>,
Will Mengarini <······@eskimo.com> wrote:
>·······@cis.ohio-state.edu (mark carroll) writes:
>
>>I'd like a data structure that listp returns NIL for,
>>that I can use as a hash table key and that I can pack
>>a few unbounded integers into. Simple vectors would be
>>the obvious choice, but even with equal hash tables,
>>unfortunately (equal (vector 1 2 3) (vector 1 2 3) returns NIL.
>
>Use an equalp hash table.
>(equalp (vector 1 2 3) (vector 1 2 3)) => T
Doh - of course! - thanks very much indeed... (-:
-- Mark
For what it's worth, you can emulate a multi-dimensional hash table by
nesting hash tables into one another, each level using a number as the
key. It can be much faster, nicer and leaner because hash tables can
use #'eql and you don't have to cons just to get a multidimensional key.
Robert
mark carroll wrote:
>
> A strange request: I'd like a data structure that listp returns NIL
> for, that I can use as a hash table key and that I can pack a few
> unbounded integers into.