On Mon, May 5, 2008 at 7:34 PM, Oliver Kullmann
<O.Kullmann at swansea.ac.uk> wrote:
> In Maxima it should be simple:
> Isn't every object a term? So just evaluate this term, take it as a string, use a standard hash function for strings, and use bucket hashing.
Maxima operations work on the internal list structure (tree). If you
want to hash the string value, you can certainly do that as well,
though it is rather inefficient.
> But the hash-table from the graphs-package works normally!
No, this contributed package has a bug:
load(graphs)$
h: hash_table()$
set_hash(x^2,h,x2)$
set_hash(ratsimp(x^2),h,ratsimpx2)$
get_hash(x^2,h) => x2
get_hash(ratsimp(x^2),h) => ratsimpx2
is(x^2 = ratsimp(x^2) ) => true
Maxima expressions may be equal (predicate: alike1) as Maxima objects
without being equal as list structures. Perhaps the simplest example
is x^2 vs. ratsimp(x^2) -- internal forms ((mexpt simp) $x 2) and
((mexpt simp ratsimp) $x 2). A correct hash function would ignore all
the annotations (like ratsimp). Unfortunately, Common Lisp apparently
has no standard way of specifying a hash function for its hash table
operations. The simplest way to fix this is to copy the arguments,
stripping the annotations.
> What is the effect of your change below (I don't know that alike1)?
It doesn't help, since it doesn't change the hash function, only the
test function. And in fact some implementations (GCL) correctly give
an error in this case.
-s