@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
47 lines • 12.3 kB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="theme-color" content="#273f79"/><link rel="stylesheet" href="lpdoc.css" type="text/css"/><script type="text/javascript" src="lpdoc.js"></script><title>Dictionaries — The Ciao System v1.22</title></head><body><div class="lpdoc-page fixleftbar"><a href="#" id="sidebar-toggle-button" class="lpdoc-navbutton"><span id="sidebar-button-arrow">☰</span></a><div id="sidebar" class="lpdoc-sidebar"><div style="height: 40px; margin-left: auto; margin-right: auto"><img src="ciao-logo_autofig.png" width=auto height=100%></div><div class="lpdoc-nav"><span class="lpdoc-on-right"><a class="lpdoc-navbutton" href="DataStructuresAlgs.html">↑</a><a class="lpdoc-navbutton" href="diff.html">←</a><a class="lpdoc-navbutton" href="vndict.html">→</a><a class="lpdoc-navbutton" href="ciaosearch.html">🔍</a></span><span><a href="ciaofulltoc.html">TOC</a></span></div><hr></hr><ul class="lpdoc-itemize-sectpath"><li><a href="ciao.html">The Ciao System</a> »<br/> </li><li><a href="DataStructuresAlgs.html">PART VI - Data structures and algorithms</a> »<br/> </li><li><a href=""><strong>Dictionaries</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Usage and interface">Usage and interface</a></li><li><a href="#Documentation on exports">Documentation on exports</a></li><li><a href="#Documentation on imports">Documentation on imports</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>Dictionaries</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#dict"></a>
<strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="The Ciao Development Team" href="ciaosearch.html#The Ciao Development Team">The Ciao Development Team</a>.<p>
This module provides predicates for implementing dictionaries. Such dictionaries are currently implemented as ordered binary trees of key-value pairs.<br/><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/><tt>:- use_module(library(dict)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="0" href="#dictionary/5"><tt>dictionary/5</tt></a>, <a class="lpdoc-idx-anchor" id="1" href="#dic_node/2"><tt>dic_node/2</tt></a>, <a class="lpdoc-idx-anchor" id="2" href="#dic_lookup/3"><tt>dic_lookup/3</tt></a>, <a class="lpdoc-idx-anchor" id="3" href="#dic_lookup/4"><tt>dic_lookup/4</tt></a>, <a class="lpdoc-idx-anchor" id="4" href="#dic_get/3"><tt>dic_get/3</tt></a>, <a class="lpdoc-idx-anchor" id="5" href="#dic_replace/4"><tt>dic_replace/4</tt></a>.
<li><em>Regular Types:</em><br/><a class="lpdoc-idx-anchor" id="6" href="assertions_props.html#dictionary/1"><tt>dictionary/1</tt></a>, <a class="lpdoc-idx-anchor" id="7" href="#old_or_new/1"><tt>old_or_new/1</tt></a>, <a class="lpdoc-idx-anchor" id="8" href="#non_empty_dictionary/1"><tt>non_empty_dictionary/1</tt></a>.
</ul></ul></div></div><div id="Documentation on exports"><h2>Documentation on exports</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="dictionary/1" href="ciaosearch.html#dictionary/1">dictionary/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>dictionary(D)</tt>
</span><p><span class="lpdoc-var">D</span> is a dictionary.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="dictionary/5" href="ciaosearch.html#dictionary/5">dictionary/5</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>dictionary(D,K,V,L,R)</tt>
</span><p>The dictionary node <span class="lpdoc-var">D</span> has key <span class="lpdoc-var">K</span>, value <span class="lpdoc-var">V</span>, left child <span class="lpdoc-var">L</span>, and right child <span class="lpdoc-var">R</span>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="9" href="#non_empty_dictionary/1"><tt>dict:non_empty_dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is a non-empty dictionary.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="dic_node/2" href="ciaosearch.html#dic_node/2">dic_node/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>dic_node(D,N)</tt>
</span><p><span class="lpdoc-var">N</span> is a sub-dictionary of <span class="lpdoc-var">D</span>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="10" href="#non_empty_dictionary/1"><tt>dict:non_empty_dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is a non-empty dictionary.
</span>
<li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="11" href="assertions_props.html#dictionary/1"><tt>dict:dictionary/1</tt></a>)</span><span><span class="lpdoc-var">N</span> is a dictionary.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="dic_lookup/3" href="ciaosearch.html#dic_lookup/3">dic_lookup/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>dic_lookup(D,K,V)</tt>
</span><p><span class="lpdoc-var">D</span> contains value <span class="lpdoc-var">V</span> at key <span class="lpdoc-var">K</span>. If it was not already in <span class="lpdoc-var">D</span> it is added.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="12" href="#non_empty_dictionary/1"><tt>dict:non_empty_dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is a non-empty dictionary.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="dic_lookup/4" href="ciaosearch.html#dic_lookup/4">dic_lookup/4</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>dic_lookup(D,K,V,O)</tt>
</span><p>Same as <tt>dic_lookup(D,K,V)</tt>. <span class="lpdoc-var">O</span> indicates if it was already in <span class="lpdoc-var">D</span> (<tt>old</tt>) or not (<tt>new</tt>).</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="13" href="#non_empty_dictionary/1"><tt>dict:non_empty_dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is a non-empty dictionary.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="15" href="#old_or_new/1"><tt>dict:old_or_new/1</tt></a>)</span><span><a class="lpdoc-idx-anchor" id="14" href="ciaosearch.html#old_or_new(O)"><tt>dict:old_or_new(O)</tt></a>
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="dic_get/3" href="ciaosearch.html#dic_get/3">dic_get/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>dic_get(D,K,V)</tt>
</span><p><span class="lpdoc-var">D</span> contains value <span class="lpdoc-var">V</span> at key <span class="lpdoc-var">K</span>. Fails if it is not already in <span class="lpdoc-var">D</span>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="16" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="17" href="assertions_props.html#dictionary/1"><tt>dict:dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is a dictionary.
</span>
<li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="18" href="#non_empty_dictionary/1"><tt>dict:non_empty_dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is a non-empty dictionary.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="dic_replace/4" href="ciaosearch.html#dic_replace/4">dic_replace/4</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>dic_replace(D,K,V,D1)</tt>
</span><p><span class="lpdoc-var">D</span> and <span class="lpdoc-var">D1</span> are identical except for the element at key <span class="lpdoc-var">K</span>, which in <span class="lpdoc-var">D1</span> contains value <span class="lpdoc-var">V</span>, whatever has (or whether it is) in <span class="lpdoc-var">D</span>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="19" href="assertions_props.html#dictionary/1"><tt>dict:dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is a dictionary.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="20" href="assertions_props.html#dictionary/1"><tt>dict:dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D1</span> is a dictionary.
</span>
<li><em>The following properties should hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="21" href="assertions_props.html#dictionary/1"><tt>dict:dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D</span> is a dictionary.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="22" href="assertions_props.html#dictionary/1"><tt>dict:dictionary/1</tt></a>)</span><span><span class="lpdoc-var">D1</span> is a dictionary.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="old_or_new/1" href="ciaosearch.html#old_or_new/1">old_or_new/1</a></div><div class="lpdoc-deftext">A regular type, defined as follows:<pre class="lpdoc-codeblock">old_or_new(old).
old_or_new(new).
</pre> </div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="non_empty_dictionary/1" href="ciaosearch.html#non_empty_dictionary/1">non_empty_dictionary/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>non_empty_dictionary(D)</tt>
</span><p><span class="lpdoc-var">D</span> is a non-empty dictionary.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
</div><div id="Documentation on imports"><h2>Documentation on imports</h2>This module has the following direct dependencies:<ul class="lpdoc-itemize-minus"><li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="23" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="24" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="25" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="26" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="27" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="28" href="ciaosearch.html#nortchecks"><tt>nortchecks</tt></a>, <a class="lpdoc-idx-anchor" id="29" href="isomodes_doc.html"><tt>isomodes</tt></a>.
</ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>