Re: [Scheme-reports] Seeking review of sets and hash tables proposals taylanbayirli@gmail.com (26 May 2013 10:14 UTC)
Re: [Scheme-reports] Seeking review of sets and hash tables proposals John Cowan (27 May 2013 21:00 UTC)

Re: [Scheme-reports] Seeking review of sets and hash tables proposals John Cowan 27 May 2013 20:59 UTC

Alexey Radul scripsit:

> > So far I haven't heard about any *actual* cases of people requiring
> > specialized equivalence predicates, though it's easy to make up
> > hypotheticals.
>
> Really?
>
> How about record types?  equal? is not specified to compare their
> contents recursively, so if I want those semantics I have to force
> them with a custom equivalence predicate, and therefore a custom hash
> function.  I have written a hash function because of this, so this
> meets your criterion of non-hypotheticalness.

You are the first person to say so.

> How about sets?  Suppose I want to use sets as keys in a hash table,
> with set=? as the equivalence predicate?

What's the practical application of sets as keys?

In any case, hash functions for containers are easy to write:

  (lambda (cont)
    (<container>-fold
      (lambda (elem) (xor (hash elem) acc))
      0
      cont)

where `hash` is an equality hash function.  This is perhaps an argument
for exposing `hash` from SRFI 69.

--
Note that nobody these days would clamor for fundamental laws        John Cowan
of *the theory of kangaroos*, showing why pseudo-kangaroos are   cowan@ccil.org
physically, logically, metaphysically impossible.    http://www.ccil.org/~cowan
Kangaroos are wonderful, but not *that* wonderful.     --Dan Dennett on zombies

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports