[m-dev.] for review: use bitsets in quantification

Ralph Becket rbeck at microsoft.com
Wed Nov 8 03:57:10 AEDT 2000


>From Fergus Henderson on 07/11/2000 16:46:15
> 
> `reversible_hash' is certainly a much better mnemonic than the
> `convertable_to_int' name that I suggested for the non-contiguous
> version.  It immediately suggests a use...
> 
> Does Okasaki make much use of this type class?

Er, dunno.  He does suggest that such a thing might be used to
optimise some set representations (use the int version rather
than the raw object).

However, the `_hash' part of the name suggests that the output of
to_int/1 should be a sensible hash value; the problem is that
all the useful hashing functions I can think of are many-to-one
and hence not reversible.

> > So we include (at least) to_int/1, from_int/1, first/0, last/0.
> > I think pred/1 and succ/1 should also go in there as methods
> > rather than utility functions since they may be more economically
> > implemented than
> > 	pred(X) = from_int(to_int(X) - 1)
> > 	succ(X) = from_int(to_int(X) + 1)
> 
> Could you give an example of a more economic implementation?

This is a bit contrived, but the set of strings is enumerable and
I expect it would be more efficient to work directly on the string
representation than to convert back and forth between int(eger)s.

Now you put the question, I'm having trouble thinking of a
non-contrived example...

--
Ralph Becket      |      MSR Cambridge      |      rbeck at microsoft.com 

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list