[mercury-users] Assoc-List: keys ground & values unique
Kral Stefan
skral at mips.complang.tuwien.ac.at
Fri Sep 23 03:23:57 AEST 2005
Hi Everyone.
I need to do a variant of assoc_list that can hold something unique
as the value. Of course, I tried anything promising (to me), but
it didn't quite work out.
So, assuming a data-type like
:- type gmpkv ---> index_content(int, gmpint).
and a predicate like
:- pred assoclist_fetch(int, gmpint, list(gmpkv), list(gmpkv)).
which does a lookup of the 1st arg in the 3rd, returning the 2nd and
the 4th (upon success). The returned assoclist does not contain the
key-value "pair" anymore. (I wanted to use "real" pairs at first. But
as two args are integers, that did not appear to be such a good idea...)
What should the mode declaration look like?
My first guess was
:- mode assoclist_fetch(in, uo, di, uo) is semidet.
the second one
:- mode assoclist_fetch(in, uo, di(list(unique)),
free >> unique(list(unique)))
is semidet.
then I tried all kinds of variations that describe the instantiatedness
tree in more (and more) details, yet I did not hit the right one yet.
It the problem solely on my side or it is also on the current status
of the implementation of unique modes within the Mercury compiler?
(My next step will be using unsafe_promise_unique at appropriate
places, hoping this will not kick correctness out of the window.)
I would appreciate any hint on that issue.
Best regards,
Stefan.
--
Stefan Kral http://www.complang.tuwien.ac.at/skral/
--------------------------------------------------------------------------
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