[mercury-users] Hashtable modes (foldl)

Ralph Becket rafe at cs.mu.OZ.AU
Tue Apr 11 11:50:03 AEST 2006


Robert Colvin, Tuesday, 11 April 2006:
> Hi,
> 
> Is it possible to use hash_tables as the accumulator to foldl/4?  
> 
> The mode listing for the first (pred) parameter to foldl/4 doesn't
> list "pred(in, di, out)", which appears to be what is required
> (hash_table_di = di(hash_table), hash_table_uo = out(hash_table)).

Yes, this is a problem with our mode system that we are looking into.
However, it's a research problem, so don't expect a good fix any time
soon.  [You could always use an unsafe inst cast function written in
C for now... but see my next comment first.]

> Perhaps there is another data structure I should be using instead?
> (It looks like I could get version_hash_table to work, but I won't
> need to access previous versions)

Version hash tables would be very nearly as efficient (the older
versions will be garbage collected if you don't have any references to
them).

When I benchmarked these things a couple of years ago, the speed
differences were about +/-5%.  With tens of thousands of items, hash
tables were about twice as fast as maps.  With three hundred or fewer
items, maps were as fast or faster than hash tables.

-- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list