Thanks Tomas<br>It works like this.<div><br></div><div>This is very useful to use the map library like you showed, but my original question was related to the example in the (one and only:( ) Mercury tutorial in paragraph 2. 7 :</div>
<div><a href="http://www.mercury.csse.unimelb.edu.au/information/papers/book.pdf">http://www.mercury.csse.unimelb.edu.au/information/papers/book.pdf</a></div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">:- module dictionary.</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">:- interface.</font></div><div><font class="Apple-style-span" face="'courier new', monospace">:- type dictionary(Key, Value).</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">:- pred search(dictionary(Key, Value)::in, Key::in, Value::out) is semidet.</font></div><div><font class="Apple-style-span" face="'courier new', monospace">:- func set(dictionary(Key, Value), Key, Value) = dictionary(Key, Value).</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">:- implementation.</font></div><div><font class="Apple-style-span" face="'courier new', monospace">:- import_module list.</font></div><div>
<font class="Apple-style-span" face="'courier new', monospace">:- type dictionary(Key, Value) == list({Key, Value}).</font></div><div><font class="Apple-style-span" face="'courier new', monospace">search([{K, V} | Dict], Key, Value) :-</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">( if Key = K then Value = V else search(Dict, Key, Value) ).</font></div><div><font class="Apple-style-span" face="'courier new', monospace">set(Dict, Key, Value) = [{Key, Value} | Dict].</font></div>
<div><br></div><div class="gmail_quote">I tried to make use of this module (admitedly not computationally efficient but that's not the point).</div><div class="gmail_quote">Can I use this module like is is , or is some init predicate necessary ?</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">2010/9/23 Tomas By <span dir="ltr"><<a href="mailto:tomas@basun.net">tomas@basun.net</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Thu, September 23, 2010 10:52, Tomas By wrote:<br>
> | map.insert(Dic0,"jmv","JM Vanel",Dic1),<br>
> | map.search(Dic1,"jmv",V),<br>
<br>
</div>Make that<br>
<br>
| map.det_insert(Dic0,"jmv","JM Vanel",Dic1),<br>
| map.lookup(Dic1,"jmv",V),<br>
<div><div></div><div class="h5"><br>
/Tomas<br>
<br>
<br>
--------------------------------------------------------------------------<br>
mercury-users mailing list<br>
Post messages to: <a href="mailto:mercury-users@csse.unimelb.edu.au">mercury-users@csse.unimelb.edu.au</a><br>
Administrative Queries: <a href="mailto:owner-mercury-users@csse.unimelb.edu.au">owner-mercury-users@csse.unimelb.edu.au</a><br>
Subscriptions: <a href="mailto:mercury-users-request@csse.unimelb.edu.au">mercury-users-request@csse.unimelb.edu.au</a><br>
--------------------------------------------------------------------------<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Jean-Marc Vanel<br>Consulting, services, training,<br>Rule-based programming, Semantic Web<br><a href="http://jmvanel.free.fr/">http://jmvanel.free.fr/</a><br>
EulerGUI, a turntable GUI for Semantic Web + rules, XML, UML, eCore, Java bytecode<br>+33 (0)6 89 16 29 52 -- +33 (0)1 39 55 58 16<br>( we rarely listen to voice messages, please send a mail instead )<br>
</div>