From: mark carroll
Subject: Packing numbers into an atom
Date: 
Message-ID: <8mfs1l$1rb$1@news.cis.ohio-state.edu>
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

From: Duane Rettig
Subject: Re: Packing numbers into an atom
Date: 
Message-ID: <4aeess9ic.fsf@beta.franz.com>
·······@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)
From: Will Mengarini
Subject: Re: Packing numbers into an atom
Date: 
Message-ID: <8mgmlh$ut0$1@eskinews.eskimo.com>
·······@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.
From: mark carroll
Subject: Re: Packing numbers into an atom
Date: 
Message-ID: <8mh6hj$op6$1@news.cis.ohio-state.edu>
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
From: Robert Monfera
Subject: Re: Packing numbers into an atom
Date: 
Message-ID: <398C52CA.29F1D3B5@fisec.com>
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.