[mercury-users] Hash_table initialization

Goncalo Jorge Coelho e Silva l10454 at alunos.uevora.pt
Wed Apr 30 10:31:00 AEST 2003


Hi,

 I tried to used hash_tables and
had a few problems regarding initialization.

 I am unsure whether I have to use predicates,
where I explicitly define the default size and
occupancy arguments, like in:

:- func new(hash_pred(K), int, float) = hash_table(K, V).


 I tried this code (which didn't compile ;) ):

:- import_module io.

:- pred main(io__state, io__state).
:- mode main(di, uo) is det.
%:- mode main(di, uo) is semidet.
%:- mode main(di, uo) is cc_multi.

:- pred seee(string, io__state, io__state).
:- mode seee(in, di, uo)is semidet.

:- implementation.
:- import_module string.
:- import_module hash_table.

%main -->
main(IO0,IO):-
        det_insert(hash_table(K, V), K, V) = MyHashTable(K, V),
        %set(hash_table(key, value), key, value) = HT,
        %set(HT, key, value) = hash_table(key, value),
        %set(hash_table(key, value), key, value) = hash_table(key, value),
        io__write_string("It's harder to see it.", IO0, IO).



Compilation result is: 

inter.m:019: In clause for predicate `inter:main/2':
inter.m:019:   warning: variable `MyHashTable' occurs only once in this
scope.
inter.m:019: In clause for predicate `inter:main/2':
inter.m:019:   in argument 1 of functor `det_insert/3':
inter.m:019:   error: undefined symbol `hashtable/2'.
inter.m:010: Error: no clauses for predicate `inter:seee/3'.
make: *** [run] Error 1



Do I need to use 'new(hash_pred(K),...)' ?

And how should I use it?

Thanks again.

Cheers,
Goncalo

--------------------------------------------------------------------------
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