@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
24 lines (20 loc) • 6.24 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>Randomized aggregates — 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="ExtraLibs.html">↑</a><a class="lpdoc-navbutton" href="random.html">←</a><a class="lpdoc-navbutton" href="sockets.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="ExtraLibs.html">PART VIII - Additional libraries</a> »<br/> </li><li><a href=""><strong>Randomized aggregates</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>Randomized aggregates</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#random_aggregates"></a>
<strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Jose F. Morales" href="ciaosearch.html#Jose F. Morales">Jose F. Morales</a>.<p>
This module implements randomized version of <a class="lpdoc-idx-anchor" id="0" href="ciaosearch.html#aggregates">aggregates</a> predicates.<p>Example 1: <pre class="lpdoc-codeblock">?- random_findall(4, X, between(1,10000,X), Xs).
Xs = [6659,7135,7871,9864] ?
yes
</pre> <p>Example 2: <pre class="lpdoc-codeblock">?- random_findall(4, X, member(X, [the,sequel,will,not,happen]), Xs).
Xs = [the,sequel,will,happen] ?
yes
</pre> <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(random_aggregates)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="1" href="#random_findall/4"><tt>random_findall/4</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">PREDICATE</span><a class="lpdoc-idx-anchor" id="random_findall/4" href="ciaosearch.html#random_findall/4">random_findall/4</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl"><tt>random_findall(K,X,Goal,Ys)</tt>
</span><p>This predicate implements the <a href="https://en.wikipedia.org/wiki/Reservoir_sampling">reservoir sampling algorithm</a>. It needs to evaluate all solutions to <span class="lpdoc-var">Goal</span> but only need to keeps <span class="lpdoc-var">K</span> of those solutions in memory simultaneously.<p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>random_findall(K,X,Goal,Ys)</tt>
</span><p>Obtains a list <span class="lpdoc-var">Ys</span> of length <span class="lpdoc-var">K</span> of random solutions uniformly distributed from <span class="lpdoc-var">X</span> for all solutions to <span class="lpdoc-var">Goal</span>. Fails if there are less than <span class="lpdoc-var">K</span> solutions.</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="2" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">K</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="3" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">X</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="4" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Goal</span> is currently a term which is not a free variable.
</span>
</ul>
<em>Meta-predicate</em> with arguments: <tt>random_findall(?,?,goal,?)</tt>.<br/></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>System library modules:</em><br/><a class="lpdoc-idx-anchor" id="5" href="ciaosearch.html#native_props"><tt>native_props</tt></a>, <a class="lpdoc-idx-anchor" id="6" href="datafacts_rt.html"><tt>datafacts_rt</tt></a>, <a class="lpdoc-idx-anchor" id="7" href="aggregates.html"><tt>aggregates</tt></a>, <a class="lpdoc-idx-anchor" id="8" href="random.html"><tt>random</tt></a>.
<li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="9" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="10" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="11" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="12" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="13" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="14" href="isomodes_doc.html"><tt>isomodes</tt></a>, <a class="lpdoc-idx-anchor" id="15" href="ciaosearch.html#nativeprops"><tt>nativeprops</tt></a>, <a class="lpdoc-idx-anchor" id="16" href="ciaosearch.html#hiord"><tt>hiord</tt></a>, <a class="lpdoc-idx-anchor" id="17" href="datafacts_doc.html"><tt>datafacts</tt></a>.
</ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>