[mercury-users] Inst problem with hash tables

Paul Bone pbone at csse.unimelb.edu.au
Sat Sep 20 10:33:31 AEST 2008


On Fri, Sep 19, 2008 at 05:32:09PM +0200, andrea bini wrote:
> Hi all,
> I have a problem with insts when reading from a file a hash table, created using new_default function from hash_table.m, previously saved with io.write_binary. Maybe is a silly question but when I read the hash table using io.read_binary the instantiation state of it is ground and is not compatible with inst hash_table used by all the predicates and functions in hash_table.m. Indeed I cannot call any predicate on it.
> 
> How can I use mercury libraries to save an hash_table on a file and use it again after it has been read?
> 
> Thanks a lot!

Hi Andrea,

The simplest way I can imagine to do this is to use the to_assoc_list
and from_assoc_list functions defined in the hash_table module, and
writing the associated list out to disk.  You will need to provide the
hashing function to from_assoc_list so it can recompute the hashes and
fill the table.

Hope this helps.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/users/attachments/20080920/c7503be4/attachment.sig>


More information about the users mailing list