⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit-data-structures.html

📁 Scheme跨平台编译器
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<B><FONT COLOR="#A020F0">=&gt;</FONT></B>  <B><FONT COLOR="#BC8F8F">&quot;&amp;lt;h1&amp;gt;this is a &amp;quot;string&amp;quot;&amp;lt;/h1&amp;gt;&quot;</FONT></B></PRE><a name="substring"></a><h3>substring=?</h3><pre>[procedure] (substring=? STRING1 STRING2 [START1 [START2 [LENGTH]]])[procedure] (substring-ci=? STRING1 STRING2 [START1 [START2 [LENGTH]]])</pre><p>Returns <tt>#t</tt> if the strings <tt>STRING1</tt> and <tt>STRING2</tt> are equal, or <tt>#f</tt> otherwise. The comparison starts at the positions <tt>START1</tt> and <tt>START2</tt> (which default to 0), comparing <tt>LENGTH</tt> characters (which defaults to the minimum of the remaining length of both strings).</p><a name="substring-index"></a><h3>substring-index</h3><pre>[procedure] (substring-index WHICH WHERE [START])[procedure] (substring-index-ci WHICH WHERE [START])</pre><p>Searches for first index in string <tt>WHERE</tt> where string <tt>WHICH</tt> occurs.  If the optional argument <tt>START</tt> is given, then the search starts at that index.  <tt>substring-index-ci</tt> is a case-insensitive version of <tt>substring-index</tt>.</p><a name="combinators"></a><h2>Combinators</h2><a name="any"></a><h3>any?</h3><pre>[procedure] (any? X)</pre><p>Ignores its argument and always returns <tt>#t</tt>. This is actually useful sometimes.</p><a name="none"></a><h3>none?</h3><pre>[procedure] (none? X)</pre><p>Ignores its argument and always returns <tt>#f</tt>. This is actually useful sometimes.</p><a name="always"></a><h3>always?</h3><pre>[procedure] (always? X)</pre><p>Ignores its arguments and always returns <tt>#t</tt>. This is actually useful sometimes.</p><a name="never"></a><h3>never?</h3><pre>[procedure] (never? X)</pre><p>Ignores its arguments and always returns <tt>#f</tt>. This is actually useful sometimes.</p><a name="constantly"></a><h3>constantly</h3><pre>[procedure] (constantly X ...)</pre><p>Returns a procedure that always returns the values <tt>X ...</tt> regardless of the number and value of its arguments.</p><PRE>(constantly X) &lt;<B><FONT COLOR="#A020F0">=&gt;</FONT></B> (<B><FONT COLOR="#A020F0">lambda</FONT></B> args X)</PRE><a name="complement"></a><h3>complement</h3><pre>[procedure] (complement PROC)</pre><p>Returns a procedure that returns the boolean inverse of <tt>PROC</tt>.</p><PRE>(complement PROC) &lt;<B><FONT COLOR="#A020F0">=&gt;</FONT></B> (<B><FONT COLOR="#A020F0">lambda</FONT></B> (x) (not (PROC x)))</PRE><a name="compose"></a><h3>compose</h3><pre>[procedure] (compose PROC1 PROC2 ...)</pre><p>Returns a procedure that represents the composition of the argument-procedures <tt>PROC1 PROC2 ...</tt>.</p><PRE>(compose F G) &lt;<B><FONT COLOR="#A020F0">=&gt;</FONT></B> (<B><FONT COLOR="#A020F0">lambda</FONT></B> args                      (call-with-values                         (<B><FONT COLOR="#A020F0">lambda</FONT></B> () (apply G args))                         F))</PRE><p><tt>(compose)</tt> is equivalent to <tt>values</tt>.</p><a name="conjoin"></a><h3>conjoin</h3><pre>[procedure] (conjoin PRED ...)</pre><p>Returns a procedure that returns <tt>#t</tt> if its argument satisfies the predicates <tt>PRED ...</tt>. <PRE>((conjoin odd? positive?) 33)   =<B><FONT COLOR="#A020F0">=&gt;</FONT></B>  #t((conjoin odd? positive?) -33)  =<B><FONT COLOR="#A020F0">=&gt;</FONT></B>  #f</PRE></p><a name="disjoin"></a><h3>disjoin</h3><pre>[procedure] (disjoin PRED ...)</pre><p>Returns a procedure that returns <tt>#t</tt> if its argument satisfies any predicate <tt>PRED ...</tt>. <PRE>((disjoin odd? positive?) 32)    =<B><FONT COLOR="#A020F0">=&gt;</FONT></B>  #t((disjoin odd? positive?) -32)   =<B><FONT COLOR="#A020F0">=&gt;</FONT></B>  #f</PRE></p><a name="each"></a><h3>each</h3><pre>[procedure] (each PROC ...)</pre><p>Returns a procedure that applies <tt>PROC ...</tt> to its arguments, and returns the result(s) of the last procedure application. For example</p><PRE>(each pp eval)</PRE><p>is equivalent to</p><PRE>(<B><FONT COLOR="#A020F0">lambda</FONT></B> args   (apply pp args)  (apply eval args) )</PRE><p><tt>(each PROC)</tt> is equivalent to <tt>PROC</tt> and <tt>(each)</tt> is equivalent to <tt>noop</tt>.</p><a name="flip"></a><h3>flip</h3><pre>[procedure] (flip PROC)</pre><p>Returns a two-argument procedure that calls <tt>PROC</tt> with its arguments swapped: <PRE>(flip PROC) &lt;<B><FONT COLOR="#A020F0">=&gt;</FONT></B> (<B><FONT COLOR="#A020F0">lambda</FONT></B> (x y) (PROC y x))</PRE></p><a name="identity"></a><h3>identity</h3><pre>[procedure] (identity X)</pre><p>Returns its sole argument <tt>X</tt>.</p><a name="project"></a><h3>project</h3><pre>[procedure] (project N)</pre><p>Returns a procedure that returns its <tt>N</tt>th argument (starting from 0).</p><a name="list-of"></a><h3>list-of</h3><pre>[procedure] (list-of PRED)</pre><p>Returns a procedure of one argument that returns <tt>#t</tt> when applied to a list of elements that all satisfy the predicate procedure <tt>PRED</tt>, or <tt>#f</tt> otherwise.</p><PRE>((list-of even?) '(1 2 3))   =<B><FONT COLOR="#A020F0">=&gt;</FONT></B> #f((list-of number?) '(1 2 3)) =<B><FONT COLOR="#A020F0">=&gt;</FONT></B> #t</PRE><a name="noop"></a><h3>noop</h3><pre>[procedure] (noop X ...)</pre><p>Ignores it's arguments, does nothing and returns an unspecified value.</p><a name="o"></a><h3>o</h3><pre>[procedure] (o PROC ...)</pre><p>A single value version of <tt>compose</tt> (slightly faster). <tt>(o)</tt> is equivalent to <tt>identity</tt>.</p><a name="left-section"></a><h3>left-section</h3><pre>[procedure] (left-section PROC ARG0 ...)</pre><p>Returns a procedure that partially applies some of its' arguments starting from the left.</p><p><tt>PROC</tt> a procedure.</p><p><tt>ARG0 ...</tt> some prefix of the arguments for <tt>PROC</tt>.</p><a name="right-section"></a><h3>right-section</h3><pre>[procedure] (right-section PROC ARG0 ...)</pre><p>Returns a procedure that partially applies some of its' arguments starting from the right.</p><p><tt>PROC</tt> a procedure.</p><p><tt>ARG0 ...</tt> some reversed suffix of the arguments for <tt>PROC</tt>.</p><a name="binary-searching"></a><h2>Binary searching</h2><a name="binary-search"></a><h3>binary-search</h3><pre>[procedure] (binary-search SEQUENCE PROC)</pre><p>Performs a binary search in <tt>SEQUENCE</tt>, which should be a sorted list or vector.  <tt>PROC</tt> is called to compare items in the sequence, should accept a single argument and return an exact integer: zero if the searched value is equal to the current item, negative if the searched value is <em>less</em> than the current item, and positive otherwise. Returns the index of the found value or <tt>#f</tt> otherwise.</p><p>Previous: <a href="unit-eval.html" class="internal">Unit eval</a></p><p>Next: <a href="unit-ports.html" class="internal">Unit ports</a></p></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -