UNPKG

@ciao-lang/ts-ciao-interface

Version:

Simple Ciao interface for node.

44 lines 11.2 kB
<!DOCTYPE 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>Random numbers &mdash; 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">&#9776;</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">&#x2191;</a><a class="lpdoc-navbutton" href="librowser.html">&#x2190;</a><a class="lpdoc-navbutton" href="random_aggregates.html">&#x2192;</a><a class="lpdoc-navbutton" href="ciaosearch.html">&#x1F50D;</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> &raquo;<br/> </li><li><a href="ExtraLibs.html">PART VIII - Additional libraries</a> &raquo;<br/> </li><li><a href=""><strong>Random numbers</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>Random numbers</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#random"></a> <strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Daniel Cabeza" href="ciaosearch.html#Daniel Cabeza">Daniel Cabeza</a>.<p> This module provides predicates for generating pseudo-random numbers<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)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="0" href="#random/1"><tt>random/1</tt></a>, <a class="lpdoc-idx-anchor" id="1" href="#random/3"><tt>random/3</tt></a>, <a class="lpdoc-idx-anchor" id="2" href="#srandom/1"><tt>srandom/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">PREDICATE</span><a class="lpdoc-idx-anchor" id="random/1" href="ciaosearch.html#random/1">random/1</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl"><tt>random(Number)</tt> </span><p><span class="lpdoc-var">Number</span> is a (pseudo-) random number in the range [0.0,1.0]<p><span class="lpdoc-usage-header">Usage:</span><p></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="3" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Number</span> is a free variable. </span> <li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="4" href="term_typing.html#float/1"><tt>term_typing:float/1</tt></a>)</span><span><span class="lpdoc-var">Number</span> is currently instantiated to a float. </span> <li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="6" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="5" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="random/3" href="ciaosearch.html#random/3">random/3</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl"><tt>random(Low,Up,Number)</tt> </span><p><span class="lpdoc-var">Number</span> is a (pseudo-) random number in the range [<span class="lpdoc-var">Low</span>, <span class="lpdoc-var">Up</span>]<p><span class="lpdoc-usage-header">Usage 1:</span><p>If <span class="lpdoc-var">Low</span> and <span class="lpdoc-var">Up</span> are integers, <span class="lpdoc-var">Number</span> is an integer.</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="7" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Low</span> is an integer. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="8" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Up</span> is an integer. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="9" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Number</span> is a free variable. </span> <li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="10" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Number</span> is an integer. </span> <li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="12" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="11" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied. </span> </ul><p><span class="lpdoc-usage-header">Usage 2:</span><p></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="13" href="basic_props.html#flt/1"><tt>basic_props:flt/1</tt></a>)</span><span><span class="lpdoc-var">Low</span> is a float. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="14" href="basic_props.html#num/1"><tt>basic_props:num/1</tt></a>)</span><span><span class="lpdoc-var">Up</span> is a number. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="15" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Number</span> is a free variable. </span> <li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="16" href="basic_props.html#flt/1"><tt>basic_props:flt/1</tt></a>)</span><span><span class="lpdoc-var">Number</span> is a float. </span> </ul><p><span class="lpdoc-usage-header">Usage 3:</span><p></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="17" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Low</span> is an integer. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="18" href="basic_props.html#flt/1"><tt>basic_props:flt/1</tt></a>)</span><span><span class="lpdoc-var">Up</span> is a float. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="19" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Number</span> is a free variable. </span> <li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="20" href="basic_props.html#flt/1"><tt>basic_props:flt/1</tt></a>)</span><span><span class="lpdoc-var">Number</span> is a float. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="srandom/1" href="ciaosearch.html#srandom/1">srandom/1</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl"><tt>srandom(Seed)</tt> </span><p>Changes the sequence of pseudo-random numbers according to <span class="lpdoc-var">Seed</span>. The starting sequence of numbers generated can be duplicated by calling the predicate with <span class="lpdoc-var">Seed</span> unbound (the sequence depends on the OS).<p><span class="lpdoc-usage-header">Usage:</span><p></p><ul class="lpdoc-itemize-minus"><li><em>Calls should, and exit will be compatible with:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="21" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Seed</span> is an integer. </span> <li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="22" href="basic_props.html#int/1"><tt>basic_props:int/1</tt></a>)</span><span><span class="lpdoc-var">Seed</span> is an integer. </span> <li><em>The following properties hold globally:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="24" href="foreign_interface_properties.html#foreign_low/2"><tt>foreign_interface_properties:foreign_low/2</tt></a>)</span><span>The Prolog predicate <a class="lpdoc-idx-anchor" id="23" href="ciaosearch.html#PrologName"><tt>PrologName</tt></a> is implemented using the function <tt>ForeignName</tt>. The same considerations as above example are to be applied. </span> </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>System library modules:</em><br/><a class="lpdoc-idx-anchor" id="25" href="foreign_interface_properties.html"><tt>foreign_interface_properties</tt></a>. <li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="26" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="27" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="28" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="29" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="30" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="31" href="isomodes_doc.html"><tt>isomodes</tt></a>, <a class="lpdoc-idx-anchor" id="32" href="foreign_interface_doc.html"><tt>foreign_interface</tt></a>, <a class="lpdoc-idx-anchor" id="33" href="basicmodes_doc.html"><tt>basicmodes</tt></a>, <a class="lpdoc-idx-anchor" id="34" href="regtypes_doc.html"><tt>regtypes</tt></a>, <a class="lpdoc-idx-anchor" id="35" href="ciaosearch.html#engine(foreign_types)"><tt>engine(foreign_types)</tt></a>. </ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>