klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 4b21b2d7ab8effb2c75e9a6eb920c2edaddaa239
parent 7594257e3af614efb6268cc3e636d60656b58980
Author: Andres Navarro <canavarro82@gmail.com>
Date:   Wed,  8 Jun 2011 17:03:57 -0300

Completed the string module in the manual.

Diffstat:
Mmanual/html/Characters.html | 42+++++++++++++++++++++---------------------
Mmanual/html/Index.html | 91+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
Mmanual/html/Ports.html | 50+++++++++++++++++++++++++-------------------------
Mmanual/html/Strings.html | 139+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mmanual/klisp.info | 136+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Mmanual/src/strings.texi | 128+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/kgstrings.c | 3+++
7 files changed, 506 insertions(+), 83 deletions(-)

diff --git a/manual/html/Characters.html b/manual/html/Characters.html @@ -34,7 +34,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <!-- node-name, next, previous, up --> <h2 class="chapter">15 Characters</h2> -<p><a name="index-characters-152"></a> +<p><a name="index-characters-175"></a> A character is an object that represents an ASCII character (for now, only ASCII is supported in klisp, in the future, full UNICODE will be supported). The external representation of characters @@ -47,50 +47,50 @@ encapsulated. features defined here were taken mostly from r5rs scheme. <div class="defun"> -&mdash; Applicative: <b>char?</b> (<var>char? . objects</var>)<var><a name="index-char_003f-153"></a></var><br> +&mdash; Applicative: <b>char?</b> (<var>char? . objects</var>)<var><a name="index-char_003f-176"></a></var><br> <blockquote><p> The primitive type predicate for type character. <code>char?</code> returns true iff all the objects in <code>objects</code> are of type character. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>char=?</b> (<var>char=? . chars</var>)<var><a name="index-char_003d_003f-154"></a></var><br> -&mdash; Applicative: <b>char&lt;?</b> (<var>char&lt;? . chars</var>)<var><a name="index-char_003c_003f-155"></a></var><br> -&mdash; Applicative: <b>char&lt;=?</b> (<var>char&lt;=? . chars</var>)<var><a name="index-char_003c_003d_003f-156"></a></var><br> -&mdash; Applicative: <b>char&gt;?</b> (<var>char&gt;? . chars</var>)<var><a name="index-char_003e_003f-157"></a></var><br> -&mdash; Applicative: <b>char&gt;=?</b> (<var>char&gt;=? . chars</var>)<var><a name="index-char_003e_003d_003f-158"></a></var><br> +&mdash; Applicative: <b>char=?</b> (<var>char=? . chars</var>)<var><a name="index-char_003d_003f-177"></a></var><br> +&mdash; Applicative: <b>char&lt;?</b> (<var>char&lt;? . chars</var>)<var><a name="index-char_003c_003f-178"></a></var><br> +&mdash; Applicative: <b>char&lt;=?</b> (<var>char&lt;=? . chars</var>)<var><a name="index-char_003c_003d_003f-179"></a></var><br> +&mdash; Applicative: <b>char&gt;?</b> (<var>char&gt;? . chars</var>)<var><a name="index-char_003e_003f-180"></a></var><br> +&mdash; Applicative: <b>char&gt;=?</b> (<var>char&gt;=? . chars</var>)<var><a name="index-char_003e_003d_003f-181"></a></var><br> <blockquote><p> These predicates compare any number of characters using their ASCII value for the comparison. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>char-ci=?</b> (<var>char-ci=? . chars</var>)<var><a name="index-char_002dci_003d_003f-159"></a></var><br> -&mdash; Applicative: <b>char-ci&lt;?</b> (<var>char-ci&lt;? . chars</var>)<var><a name="index-char_002dci_003c_003f-160"></a></var><br> -&mdash; Applicative: <b>char-ci&lt;=?</b> (<var>char-ci&lt;=? . chars</var>)<var><a name="index-char_002dci_003c_003d_003f-161"></a></var><br> -&mdash; Applicative: <b>char-ci&gt;?</b> (<var>char-ci&gt;? . chars</var>)<var><a name="index-char_002dci_003e_003f-162"></a></var><br> -&mdash; Applicative: <b>char-ci&gt;=?</b> (<var>char-ci&gt;=? . chars</var>)<var><a name="index-char_002dci_003e_003d_003f-163"></a></var><br> +&mdash; Applicative: <b>char-ci=?</b> (<var>char-ci=? . chars</var>)<var><a name="index-char_002dci_003d_003f-182"></a></var><br> +&mdash; Applicative: <b>char-ci&lt;?</b> (<var>char-ci&lt;? . chars</var>)<var><a name="index-char_002dci_003c_003f-183"></a></var><br> +&mdash; Applicative: <b>char-ci&lt;=?</b> (<var>char-ci&lt;=? . chars</var>)<var><a name="index-char_002dci_003c_003d_003f-184"></a></var><br> +&mdash; Applicative: <b>char-ci&gt;?</b> (<var>char-ci&gt;? . chars</var>)<var><a name="index-char_002dci_003e_003f-185"></a></var><br> +&mdash; Applicative: <b>char-ci&gt;=?</b> (<var>char-ci&gt;=? . chars</var>)<var><a name="index-char_002dci_003e_003d_003f-186"></a></var><br> <blockquote><p> These predicates convert the chars to lowercase and then compare their ASCII values. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>char-alphabetic?</b> (<var>char-alphabetic? . chars</var>)<var><a name="index-char_002dalphabetic_003f-164"></a></var><br> -&mdash; Applicative: <b>char-numeric?</b> (<var>char-numeric? . chars</var>)<var><a name="index-char_002dnumeric_003f-165"></a></var><br> -&mdash; Applicative: <b>char-whitespace?</b> (<var>char-whitespace? . chars</var>)<var><a name="index-char_002dwhitespace_003f-166"></a></var><br> +&mdash; Applicative: <b>char-alphabetic?</b> (<var>char-alphabetic? . chars</var>)<var><a name="index-char_002dalphabetic_003f-187"></a></var><br> +&mdash; Applicative: <b>char-numeric?</b> (<var>char-numeric? . chars</var>)<var><a name="index-char_002dnumeric_003f-188"></a></var><br> +&mdash; Applicative: <b>char-whitespace?</b> (<var>char-whitespace? . chars</var>)<var><a name="index-char_002dwhitespace_003f-189"></a></var><br> <blockquote><p> These predicates return true iff all of their arguments are respectively &ldquo;alphabetic&rdquo;, &ldquo;numeric&rdquo;, or &ldquo;whitespace&rdquo;. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>char-upper-case?</b> (<var>char-upper-case? . chars</var>)<var><a name="index-char_002dupper_002dcase_003f-167"></a></var><br> -&mdash; Applicative: <b>char-lower-case?</b> (<var>char-lower-case? . chars</var>)<var><a name="index-char_002dlower_002dcase_003f-168"></a></var><br> +&mdash; Applicative: <b>char-upper-case?</b> (<var>char-upper-case? . chars</var>)<var><a name="index-char_002dupper_002dcase_003f-190"></a></var><br> +&mdash; Applicative: <b>char-lower-case?</b> (<var>char-lower-case? . chars</var>)<var><a name="index-char_002dlower_002dcase_003f-191"></a></var><br> <blockquote><p> These predicates return true iff all of their arguments are respectively &ldquo;upper case, or &ldquo;lower case&rdquo;. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>char-upcase</b> (<var>char-upcase char</var>)<var><a name="index-char_002dupcase-169"></a></var><br> -&mdash; Applicative: <b>char-downcase</b> (<var>char-downcase char</var>)<var><a name="index-char_002ddowncase-170"></a></var><br> +&mdash; Applicative: <b>char-upcase</b> (<var>char-upcase char</var>)<var><a name="index-char_002dupcase-192"></a></var><br> +&mdash; Applicative: <b>char-downcase</b> (<var>char-downcase char</var>)<var><a name="index-char_002ddowncase-193"></a></var><br> <blockquote><p> These applicatives return a character <code>char2</code> so that: <pre class="example"> (char-ci=? char char2) &rArr; #t </pre> @@ -102,8 +102,8 @@ respectively &ldquo;upper case, or &ldquo;lower case&rdquo;. </blockquote></div> <div class="defun"> -&mdash; Applicative: <b>char-&gt;integer</b> (<var>char-&gt;integer char</var>)<var><a name="index-char_002d_003einteger-171"></a></var><br> -&mdash; Applicative: <b>integer-&gt;char</b> (<var>integer-&gt;char k</var>)<var><a name="index-integer_002d_003echar-172"></a></var><br> +&mdash; Applicative: <b>char-&gt;integer</b> (<var>char-&gt;integer char</var>)<var><a name="index-char_002d_003einteger-194"></a></var><br> +&mdash; Applicative: <b>integer-&gt;char</b> (<var>integer-&gt;char k</var>)<var><a name="index-integer_002d_003echar-195"></a></var><br> <blockquote><p> These applicatives convert between ASCII values (as exact integers between 0 and 127) and characters. If an integer that is out of range for ASCII characters is passed to <code>integer-&gt;char</code>, an error is diff --git a/manual/html/Index.html b/manual/html/Index.html @@ -55,7 +55,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <li><a href="Control.html#index-g_t_0024sequence-30"><code>$sequence</code></a>: <a href="Control.html#Control">Control</a></li> <li><a href="Environments.html#index-g_t_0024set_0021-111"><code>$set!</code></a>: <a href="Environments.html#Environments">Environments</a></li> <li><a href="Combiners.html#index-g_t_0024vau-119"><code>$vau</code></a>: <a href="Combiners.html#Combiners">Combiners</a></li> -<li><a href="Ports.html#index-g_t_0028-177"><code>(</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-g_t_0028-200"><code>(</code></a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="Continuations.html#index-g_t_0028-135"><code>(</code></a>: <a href="Continuations.html#Continuations">Continuations</a></li> <li><a href="Environments.html#index-g_t_0028-110"><code>(</code></a>: <a href="Environments.html#Environments">Environments</a></li> <li><a href="Booleans.html#index-and_003f-15"><code>and?</code></a>: <a href="Booleans.html#Booleans">Booleans</a></li> @@ -84,8 +84,8 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <li><a href="Pairs-and-lists.html#index-cadddr-66"><code>cadddr</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-caddr-54"><code>caddr</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-cadr-48"><code>cadr</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> -<li><a href="Ports.html#index-call_002dwith_002dinput_002dfile-187"><code>call-with-input-file</code></a>: <a href="Ports.html#Ports">Ports</a></li> -<li><a href="Ports.html#index-call_002dwith_002doutput_002dfile-188"><code>call-with-output-file</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-call_002dwith_002dinput_002dfile-210"><code>call-with-input-file</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-call_002dwith_002doutput_002dfile-211"><code>call-with-output-file</code></a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="Continuations.html#index-call_002fcc-128"><code>call/cc</code></a>: <a href="Continuations.html#Continuations">Continuations</a></li> <li><a href="Pairs-and-lists.html#index-car-45"><code>car</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-cdaaar-67"><code>cdaaar</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> @@ -103,26 +103,26 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <li><a href="Pairs-and-lists.html#index-cdddr-58"><code>cdddr</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-cddr-50"><code>cddr</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-cdr-46"><code>cdr</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> -<li><a href="Characters.html#index-char_002d_003einteger-171"><code>char-&gt;integer</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dalphabetic_003f-164"><code>char-alphabetic?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dci_003c_003d_003f-161"><code>char-ci&lt;=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dci_003c_003f-160"><code>char-ci&lt;?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dci_003d_003f-159"><code>char-ci=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dci_003e_003d_003f-163"><code>char-ci&gt;=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dci_003e_003f-162"><code>char-ci&gt;?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002ddowncase-170"><code>char-downcase</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dlower_002dcase_003f-168"><code>char-lower-case?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dnumeric_003f-165"><code>char-numeric?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dupcase-169"><code>char-upcase</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dupper_002dcase_003f-167"><code>char-upper-case?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_002dwhitespace_003f-166"><code>char-whitespace?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_003c_003d_003f-156"><code>char&lt;=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_003c_003f-155"><code>char&lt;?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_003d_003f-154"><code>char=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_003e_003d_003f-158"><code>char&gt;=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_003e_003f-157"><code>char&gt;?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-char_003f-153"><code>char?</code></a>: <a href="Characters.html#Characters">Characters</a></li> -<li><a href="Characters.html#index-characters-152">characters</a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002d_003einteger-194"><code>char-&gt;integer</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dalphabetic_003f-187"><code>char-alphabetic?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dci_003c_003d_003f-184"><code>char-ci&lt;=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dci_003c_003f-183"><code>char-ci&lt;?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dci_003d_003f-182"><code>char-ci=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dci_003e_003d_003f-186"><code>char-ci&gt;=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dci_003e_003f-185"><code>char-ci&gt;?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002ddowncase-193"><code>char-downcase</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dlower_002dcase_003f-191"><code>char-lower-case?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dnumeric_003f-188"><code>char-numeric?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dupcase-192"><code>char-upcase</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dupper_002dcase_003f-190"><code>char-upper-case?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_002dwhitespace_003f-189"><code>char-whitespace?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_003c_003d_003f-179"><code>char&lt;=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_003c_003f-178"><code>char&lt;?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_003d_003f-177"><code>char=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_003e_003d_003f-181"><code>char&gt;=?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_003e_003f-180"><code>char&gt;?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-char_003f-176"><code>char?</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Characters.html#index-characters-175">characters</a>: <a href="Characters.html#Characters">Characters</a></li> <li><a href="Combiners.html#index-combiner_003f-125"><code>combiner?</code></a>: <a href="Combiners.html#Combiners">Combiners</a></li> <li><a href="Combiners.html#index-combiners-114">combiners</a>: <a href="Combiners.html#Combiners">Combiners</a></li> <li><a href="Pairs-and-lists.html#index-cons-39"><code>cons</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> @@ -140,7 +140,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <li><a href="Pairs-and-lists.html#index-encycle_0021-77"><code>encycle!</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Environments.html#index-environment_003f-95"><code>environment?</code></a>: <a href="Environments.html#Environments">Environments</a></li> <li><a href="Environments.html#index-environments-93">environments</a>: <a href="Environments.html#Environments">Environments</a></li> -<li><a href="Ports.html#index-eof_002dobject_003f-191"><code>eof-object?</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-eof_002dobject_003f-214"><code>eof-object?</code></a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="Equivalence.html#index-eq_003f-20"><code>eq?</code></a>: <a href="Equivalence.html#Equivalence">Equivalence</a></li> <li><a href="Equivalence.html#index-equal_003f-21"><code>equal?</code></a>: <a href="Equivalence.html#Equivalence">Equivalence</a></li> <li><a href="Equivalence.html#index-equivalence-19">equivalence</a>: <a href="Equivalence.html#Equivalence">Equivalence</a></li> @@ -158,15 +158,15 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <li><a href="Promises.html#index-force-142"><code>force</code></a>: <a href="Promises.html#Promises">Promises</a></li> <li><a href="Environments.html#index-get_002dcurrent_002denvironment-102"><code>get-current-environment</code></a>: <a href="Environments.html#Environments">Environments</a></li> <li><a href="Pairs-and-lists.html#index-get_002dlist_002dmetrics-75"><code>get-list-metrics</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> -<li><a href="Ports.html#index-get_002dmodule-190"><code>get-module</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-get_002dmodule-213"><code>get-module</code></a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="Continuations.html#index-guard_002dcontinuation-130"><code>guard-continuation</code></a>: <a href="Continuations.html#Continuations">Continuations</a></li> <li><a href="Continuations.html#index-guard_002ddynamic_002dextent-136"><code>guard-dynamic-extent</code></a>: <a href="Continuations.html#Continuations">Continuations</a></li> <li><a href="Environments.html#index-ignore-94">ignore</a>: <a href="Environments.html#Environments">Environments</a></li> <li><a href="Environments.html#index-ignore_003f-96"><code>ignore?</code></a>: <a href="Environments.html#Environments">Environments</a></li> <li><a href="Control.html#index-inert-27">inert</a>: <a href="Control.html#Control">Control</a></li> <li><a href="Control.html#index-inert_003f-28"><code>inert?</code></a>: <a href="Control.html#Control">Control</a></li> -<li><a href="Ports.html#index-input_002dport_003f-175"><code>input-port?</code></a>: <a href="Ports.html#Ports">Ports</a></li> -<li><a href="Characters.html#index-integer_002d_003echar-172"><code>integer-&gt;char</code></a>: <a href="Characters.html#Characters">Characters</a></li> +<li><a href="Ports.html#index-input_002dport_003f-198"><code>input-port?</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Characters.html#index-integer_002d_003echar-195"><code>integer-&gt;char</code></a>: <a href="Characters.html#Characters">Characters</a></li> <li><a href="Kernel-History.html#index-Kernel-history-1">Kernel history</a>: <a href="Kernel-History.html#Kernel-History">Kernel History</a></li> <li><a href="Keyed-Variables.html#index-keyed-dynamic-variables-146">keyed dynamic variables</a>: <a href="Keyed-Variables.html#Keyed-Variables">Keyed Variables</a></li> <li><a href="Keyed-Variables.html#index-keyed-static-variables-148">keyed static variables</a>: <a href="Keyed-Variables.html#Keyed-Variables">Keyed Variables</a></li> @@ -174,16 +174,18 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <li><a href="Pairs-and-lists.html#index-length-79"><code>length</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-list-43"><code>list</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-list_002a-44"><code>list*</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> +<li><a href="Strings.html#index-list_002d_003estring-174"><code>list-&gt;string</code></a>: <a href="Strings.html#Strings">Strings</a></li> <li><a href="Pairs-and-lists.html#index-list_002dneighbors-82"><code>list-neighbors</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-list_002dref-80"><code>list-ref</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-list_002dtail-76"><code>list-tail</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-lists-36">lists</a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> -<li><a href="Ports.html#index-load-189"><code>load</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-load-212"><code>load</code></a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="Encapsulations.html#index-make_002dencapsulation_002dtype-139"><code>make-encapsulation-type</code></a>: <a href="Encapsulations.html#Encapsulations">Encapsulations</a></li> <li><a href="Environments.html#index-make_002denvironment-98"><code>make-environment</code></a>: <a href="Environments.html#Environments">Environments</a></li> <li><a href="Environments.html#index-make_002dkernel_002dstandard_002denvironment-103"><code>make-kernel-standard-environment</code></a>: <a href="Environments.html#Environments">Environments</a></li> <li><a href="Keyed-Variables.html#index-make_002dkeyed_002ddynamic_002dvariable-147"><code>make-keyed-dynamic-variable</code></a>: <a href="Keyed-Variables.html#Keyed-Variables">Keyed Variables</a></li> <li><a href="Keyed-Variables.html#index-make_002dkeyed_002dstatic_002dvariable-149"><code>make-keyed-static-variable</code></a>: <a href="Keyed-Variables.html#Keyed-Variables">Keyed Variables</a></li> +<li><a href="Strings.html#index-make_002dstring-163"><code>make-string</code></a>: <a href="Strings.html#Strings">Strings</a></li> <li><a href="Combiners.html#index-map-124"><code>map</code></a>: <a href="Combiners.html#Combiners">Combiners</a></li> <li><a href="Pairs-and-lists.html#index-map-78"><code>map</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-member_003f-85"><code>member?</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> @@ -194,27 +196,48 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <li><a href="Pairs-and-lists.html#index-null_003f-38"><code>null?</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Numbers.html#index-numbers-150">numbers</a>: <a href="Numbers.html#Numbers">Numbers</a></li> <li><a href="A-Sample-Applicative-Description.html#index-object-descriptions-10">object descriptions</a>: <a href="A-Sample-Applicative-Description.html#A-Sample-Applicative-Description">A Sample Applicative Description</a></li> -<li><a href="Ports.html#index-open_002dinput_002dfile-181"><code>open-input-file</code></a>: <a href="Ports.html#Ports">Ports</a></li> -<li><a href="Ports.html#index-open_002doutput_002dfile-182"><code>open-output-file</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-open_002dinput_002dfile-204"><code>open-input-file</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-open_002doutput_002dfile-205"><code>open-output-file</code></a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="A-Sample-Applicative-Description.html#index-operative-descriptions-9">operative descriptions</a>: <a href="A-Sample-Applicative-Description.html#A-Sample-Applicative-Description">A Sample Applicative Description</a></li> <li><a href="Combiners.html#index-operative_003f-117"><code>operative?</code></a>: <a href="Combiners.html#Combiners">Combiners</a></li> <li><a href="Combiners.html#index-operatives-116">operatives</a>: <a href="Combiners.html#Combiners">Combiners</a></li> <li><a href="Booleans.html#index-or_003f-16"><code>or?</code></a>: <a href="Booleans.html#Booleans">Booleans</a></li> -<li><a href="Ports.html#index-output_002dport_003f-176"><code>output-port?</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-output_002dport_003f-199"><code>output-port?</code></a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="Pairs-and-lists.html#index-pair_003f-37"><code>pair?</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-pairs-33">pairs</a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> -<li><a href="Ports.html#index-port_003f-174"><code>port?</code></a>: <a href="Ports.html#Ports">Ports</a></li> -<li><a href="Ports.html#index-ports-173">ports</a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-port_003f-197"><code>port?</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-ports-196">ports</a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="Printing-Notation.html#index-printing-notation-5">printing notation</a>: <a href="Printing-Notation.html#Printing-Notation">Printing Notation</a></li> <li><a href="Promises.html#index-promise_003f-141"><code>promise?</code></a>: <a href="Promises.html#Promises">Promises</a></li> <li><a href="Promises.html#index-promises-140">promises</a>: <a href="Promises.html#Promises">Promises</a></li> -<li><a href="Ports.html#index-read-185"><code>read</code></a>: <a href="Ports.html#Ports">Ports</a></li> +<li><a href="Ports.html#index-read-208"><code>read</code></a>: <a href="Ports.html#Ports">Ports</a></li> <li><a href="Pairs-and-lists.html#index-reduce-88"><code>reduce</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Continuations.html#index-root_002dcontinuation-132"><code>root-continuation</code></a>: <a href="Continuations.html#Continuations">Continuations</a></li> <li><a href="Pairs-and-lists.html#index-set_002dcar_0021-40"><code>set-car!</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> <li><a href="Pairs-and-lists.html#index-set_002dcdr_0021-41"><code>set-cdr!</code></a>: <a href="Pairs-and-lists.html#Pairs-and-lists">Pairs and lists</a></li> +<li><a href="Strings.html#index-string-164"><code>string</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002d_003eimmutable_002dstring-172"><code>string-&gt;immutable-string</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002d_003elist-173"><code>string-&gt;list</code></a>: <a href="Strings.html#Strings">Strings</a></li> <li><a href="Symbols.html#index-string_002d_003esymbol-25"><code>string-&gt;symbol</code></a>: <a href="Symbols.html#Symbols">Symbols</a></li> +<li><a href="Strings.html#index-string_002dappend-170"><code>string-append</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dci_003c_003d_003f-160"><code>string-ci&lt;=?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dci_003c_003f-159"><code>string-ci&lt;?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dci_003d_003f-158"><code>string-ci=?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dci_003e_003d_003f-162"><code>string-ci&gt;=?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dci_003e_003f-161"><code>string-ci&gt;?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dcopy-171"><code>string-copy</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dfill_0021-168"><code>string-fill!</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dlength-165"><code>string-length</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dref-166"><code>string-ref</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_002dset_0021-167"><code>string-set!</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_003c_003d_003f-155"><code>string&lt;=?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_003c_003f-154"><code>string&lt;?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_003d_003f-153"><code>string=?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_003e_003d_003f-157"><code>string&gt;=?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_003e_003f-156"><code>string&gt;?</code></a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-string_003f-152"><code>string?</code></a>: <a href="Strings.html#Strings">Strings</a></li> <li><a href="Strings.html#index-strings-151">strings</a>: <a href="Strings.html#Strings">Strings</a></li> +<li><a href="Strings.html#index-substring-169"><code>substring</code></a>: <a href="Strings.html#Strings">Strings</a></li> <li><a href="Symbols.html#index-symbol_002d_003estring-24"><code>symbol-&gt;string</code></a>: <a href="Symbols.html#Symbols">Symbols</a></li> <li><a href="Symbols.html#index-symbol_003f-23"><code>symbol?</code></a>: <a href="Symbols.html#Symbols">Symbols</a></li> <li><a href="Symbols.html#index-symbols-22">symbols</a>: <a href="Symbols.html#Symbols">Symbols</a></li> diff --git a/manual/html/Ports.html b/manual/html/Ports.html @@ -34,7 +34,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <!-- node-name, next, previous, up --> <h2 class="chapter">16 Ports</h2> -<p><a name="index-ports-173"></a> +<p><a name="index-ports-196"></a> A port is an object that mediates character-based input from a source or character-based output to a destination. In the former case, the port is an input port, in the latter case, an output port. @@ -53,14 +53,14 @@ normal result of a call to read). The eof type is encapsulated. klisp and was taken from Scheme. <div class="defun"> -&mdash; Applicative: <b>port?</b> (<var>port? . objects</var>)<var><a name="index-port_003f-174"></a></var><br> +&mdash; Applicative: <b>port?</b> (<var>port? . objects</var>)<var><a name="index-port_003f-197"></a></var><br> <blockquote><p> The primitive type predicate for type port. <code>port?</code> returns true iff all the objects in <code>objects</code> are of type port. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>input-port?</b> (<var>input-port? . objects</var>)<var><a name="index-input_002dport_003f-175"></a></var><br> -&mdash; Applicative: <b>output-port?</b> (<var>output-port? . objects</var>)<var><a name="index-output_002dport_003f-176"></a></var><br> +&mdash; Applicative: <b>input-port?</b> (<var>input-port? . objects</var>)<var><a name="index-input_002dport_003f-198"></a></var><br> +&mdash; Applicative: <b>output-port?</b> (<var>output-port? . objects</var>)<var><a name="index-output_002dport_003f-199"></a></var><br> <blockquote><p> Applicative <code>input-port?</code> is a predicate that returns true unless one or more of its arguments is not an input port. Applicative output-port? is a predicate that returns true unless one or more of @@ -70,8 +70,8 @@ its arguments is not an output port. </p></blockquote></div> <div class="defun"> -&mdash; with-input-from-file: <b>(</b><var>with-input-from-file string combiner</var>)<var><a name="index-g_t_0028-177"></a></var><br> -&mdash; with-output-to-file: <b>(</b><var>with-output-to-file string combiner</var>)<var><a name="index-g_t_0028-178"></a></var><br> +&mdash; with-input-from-file: <b>(</b><var>with-input-from-file string combiner</var>)<var><a name="index-g_t_0028-200"></a></var><br> +&mdash; with-output-to-file: <b>(</b><var>with-output-to-file string combiner</var>)<var><a name="index-g_t_0028-201"></a></var><br> <blockquote><!-- add xref get-current-input-port/get-current-output-port --> <p>These two applicatives open the file named in <code>string</code> for input or output, an invoke the binder of the input-port &amp; output-port @@ -88,8 +88,8 @@ klisp implementation in the near future. </p></blockquote></div> <div class="defun"> -&mdash; get-current-input-port: <b>(</b><var>get-current-input-port</var>)<var><a name="index-g_t_0028-179"></a></var><br> -&mdash; get-current-output-port: <b>(</b><var>get-current-output-port</var>)<var><a name="index-g_t_0028-180"></a></var><br> +&mdash; get-current-input-port: <b>(</b><var>get-current-input-port</var>)<var><a name="index-g_t_0028-202"></a></var><br> +&mdash; get-current-output-port: <b>(</b><var>get-current-output-port</var>)<var><a name="index-g_t_0028-203"></a></var><br> <blockquote><p> These are the accessors for the input-port and output-port keyed dynamic variables repectively. <!-- add xref to with-input-from-file, etc --> @@ -102,7 +102,7 @@ klisp implementation in the near future. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>open-input-file</b> (<var>open-input-file string</var>)<var><a name="index-open_002dinput_002dfile-181"></a></var><br> +&mdash; Applicative: <b>open-input-file</b> (<var>open-input-file string</var>)<var><a name="index-open_002dinput_002dfile-204"></a></var><br> <blockquote><p> <code>string</code> should be the name/path for an existing file. <p>Applicative <code>open-input-file</code> creates and returns an input port @@ -115,7 +115,7 @@ still missing. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>open-output-file</b> (<var>open-output-file string</var>)<var><a name="index-open_002doutput_002dfile-182"></a></var><br> +&mdash; Applicative: <b>open-output-file</b> (<var>open-output-file string</var>)<var><a name="index-open_002doutput_002dfile-205"></a></var><br> <blockquote><p> <code>string</code> should be the name/path for an existing file. <p>Applicative <code>open-output-file</code> creates and returns an output @@ -132,8 +132,8 @@ still missing. </p></blockquote></div> <div class="defun"> -&mdash; close-input-file: <b>(</b><var>close-input-file input-port</var>)<var><a name="index-g_t_0028-183"></a></var><br> -&mdash; close-output-file: <b>(</b><var>close-output-file output-port</var>)<var><a name="index-g_t_0028-184"></a></var><br> +&mdash; close-input-file: <b>(</b><var>close-input-file input-port</var>)<var><a name="index-g_t_0028-206"></a></var><br> +&mdash; close-output-file: <b>(</b><var>close-output-file output-port</var>)<var><a name="index-g_t_0028-207"></a></var><br> <blockquote><p> These applicatives close the port argument, so that no more input/output may be performed on them, and the resources can be freed. If the port was already closed these applicatives have no @@ -148,7 +148,7 @@ probably be called close-input-port &amp; close-output-port. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>read</b> (<var>read </var>[<var>input-port</var>])<var><a name="index-read-185"></a></var><br> +&mdash; Applicative: <b>read</b> (<var>read </var>[<var>input-port</var>])<var><a name="index-read-208"></a></var><br> <blockquote><p> If the <code>port</code> optional argument is not specified, then the value of the <code>input-port</code> keyed dynamic variable is used. If the port is closed, an error is signaled. @@ -164,7 +164,7 @@ still missing. </p></blockquote></div> <div class="defun"> -&mdash; write: <b>(</b><var>write object </var>[<var>port</var>])<var><a name="index-g_t_0028-186"></a></var><br> +&mdash; write: <b>(</b><var>write object </var>[<var>port</var>])<var><a name="index-g_t_0028-209"></a></var><br> <blockquote><p> If the <code>port</code> optional argument is not specified, then the value of the <code>output-port</code> keyed dynamic variable is used. If the port is closed, an error is signaled. @@ -182,8 +182,8 @@ still missing. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>call-with-input-file</b> (<var>call-with-input-file string combiner</var>)<var><a name="index-call_002dwith_002dinput_002dfile-187"></a></var><br> -&mdash; Applicative: <b>call-with-output-file</b> (<var>call-with-output-file string combiner</var>)<var><a name="index-call_002dwith_002doutput_002dfile-188"></a></var><br> +&mdash; Applicative: <b>call-with-input-file</b> (<var>call-with-input-file string combiner</var>)<var><a name="index-call_002dwith_002dinput_002dfile-210"></a></var><br> +&mdash; Applicative: <b>call-with-output-file</b> (<var>call-with-output-file string combiner</var>)<var><a name="index-call_002dwith_002doutput_002dfile-211"></a></var><br> <blockquote><p> These applicatives open file named in <code>string</code> and call their <code>combiner</code> argument in a fresh empty environment passing it as a sole operand the opened port. When/if the combiner normally returns a @@ -195,7 +195,7 @@ still missing. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>load</b> (<var>load string</var>)<var><a name="index-load-189"></a></var><br> +&mdash; Applicative: <b>load</b> (<var>load string</var>)<var><a name="index-load-212"></a></var><br> <blockquote><!-- TODO add xref, open/input, read --> <p>Applicative <code>load</code> opens for input a file named <code>string</code>; reads objects from the file until the end of the file is reached; @@ -211,7 +211,7 @@ return the value of the last evaluation. </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>get-module</b> (<var>get-module string </var>[<var>environment</var>])<var><a name="index-get_002dmodule-190"></a></var><br> +&mdash; Applicative: <b>get-module</b> (<var>get-module string </var>[<var>environment</var>])<var><a name="index-get_002dmodule-213"></a></var><br> <blockquote><!-- TODO add xref standard-environment, open/input, read --> <p>Applicative <code>get-module</code> creates a fresh standard environment; opens for input a file named <code>string</code>; reads objects from the @@ -224,7 +224,7 @@ prior to evaluating read expressions, by binding symbol </p></blockquote></div> <div class="defun"> -&mdash; Applicative: <b>eof-object?</b> (<var>eof-object? . objects</var>)<var><a name="index-eof_002dobject_003f-191"></a></var><br> +&mdash; Applicative: <b>eof-object?</b> (<var>eof-object? . objects</var>)<var><a name="index-eof_002dobject_003f-214"></a></var><br> <blockquote><p> The primitive type predicate for type eof. <code>eof-object?</code> returns true iff all the objects in <code>objects</code> are of type eof. @@ -235,7 +235,7 @@ primitive type predicates. </p></blockquote></div> <div class="defun"> -&mdash; read-char: <b>(</b><var>read-char </var>[<var>port</var>])<var><a name="index-g_t_0028-192"></a></var><br> +&mdash; read-char: <b>(</b><var>read-char </var>[<var>port</var>])<var><a name="index-g_t_0028-215"></a></var><br> <blockquote><p> If the <code>port</code> optional argument is not specified, then the value of the <code>input-port</code> keyed dynamic variable is used. If the port is closed, an error is signaled. @@ -248,7 +248,7 @@ an eof if the end of file was reached. </p></blockquote></div> <div class="defun"> -&mdash; peek-char: <b>(</b><var>peek-char </var>[<var>port</var>])<var><a name="index-g_t_0028-193"></a></var><br> +&mdash; peek-char: <b>(</b><var>peek-char </var>[<var>port</var>])<var><a name="index-g_t_0028-216"></a></var><br> <blockquote><p> If the <code>port</code> optional argument is not specified, then the value of the <code>input-port</code> keyed dynamic variable is used. If the port is closed, an error is signaled. @@ -263,7 +263,7 @@ remains unchanged so that new call to <code>peek-char</code> or </p></blockquote></div> <div class="defun"> -&mdash; char-ready?: <b>(</b><var>char-ready? </var>[<var>port</var>])<var><a name="index-g_t_0028-194"></a></var><br> +&mdash; char-ready?: <b>(</b><var>char-ready? </var>[<var>port</var>])<var><a name="index-g_t_0028-217"></a></var><br> <blockquote><p> If the <code>port</code> optional argument is not specified, then the value of the <code>input-port</code> keyed dynamic variable is used. If the port is closed, an error is signaled. @@ -278,7 +278,7 @@ the code to do this is non-portable. </p></blockquote></div> <div class="defun"> -&mdash; write-char: <b>(</b><var>write-char char </var>[<var>port</var>])<var><a name="index-g_t_0028-195"></a></var><br> +&mdash; write-char: <b>(</b><var>write-char char </var>[<var>port</var>])<var><a name="index-g_t_0028-218"></a></var><br> <blockquote><p> If the <code>port</code> optional argument is not specified, then the value of the <code>output-port</code> keyed dynamic variable is used. If the port is closed, an error is signaled. @@ -291,7 +291,7 @@ The result returned by <code>write-char</code> is inert. </p></blockquote></div> <div class="defun"> -&mdash; newline: <b>(</b><var>newline </var>[<var>port</var>])<var><a name="index-g_t_0028-196"></a></var><br> +&mdash; newline: <b>(</b><var>newline </var>[<var>port</var>])<var><a name="index-g_t_0028-219"></a></var><br> <blockquote><p> If the <code>port</code> optional argument is not specified, then the value of the <code>output-port</code> keyed dynamic variable is used. If the port is closed, an error is signaled. @@ -303,7 +303,7 @@ The result returned by <code>newline</code> is inert. </p></blockquote></div> <div class="defun"> -&mdash; display: <b>(</b><var>display object </var>[<var>port</var>])<var><a name="index-g_t_0028-197"></a></var><br> +&mdash; display: <b>(</b><var>display object </var>[<var>port</var>])<var><a name="index-g_t_0028-220"></a></var><br> <blockquote><p> If the <code>port</code> optional argument is not specified, then the value of the <code>output-port</code> keyed dynamic variable is used. If the port is closed, an error is signaled. diff --git a/manual/html/Strings.html b/manual/html/Strings.html @@ -35,7 +35,146 @@ Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a> <h2 class="chapter">14 Strings</h2> <p><a name="index-strings-151"></a> + A string is an object that represent a sequence of characters (for +now, only ASCII is supported in klisp, in the future, full UNICODE +will be supported). The external representation of strings consists +of a leading &ldquo;"&rdquo;, the characters of the string and a closing &ldquo;"&rdquo;. +Some characters should be escaped, by preceding them with a &ldquo;\&rdquo;: in +klisp these are the double quote (&ldquo;"&rdquo;) and the backslash (&ldquo;\&rdquo;). +In the future more advanced escape mechanism may be added (like in +r7rs-draft scheme, for escping common ASCII control codes and +arbitrary unicode characters). A string has a length that is fixed at +creation time, and as many characters, indexed from <code>0</code> to +<code>length-1</code>. + <p>Strings may be mutable or immutable. If an attempt is made to +mutate an immutable string, an error is signaled. Two immutable +strings are &ldquo;eq?&rdquo; iff they are &ldquo;equal?&rdquo;. Two mutable strings are +&ldquo;eq?&rdquo; if they were created by the same constructor call. Two +mutable strings are &ldquo;equal?&rdquo; iff they are &ldquo;string=?&rdquo;. For now it +is undefined if a mutable and an immutable strings that are +&ldquo;string=?&rdquo; are &ldquo;equal?&rdquo; or not. The only exception is the empty +string. There is only one empty string (all empty strings are &ldquo;eq?&rdquo; +to each other) and it should be considered immutable. Even if an +attempt is made to return a new empty string (like calling +<code>(string)</code>, the canonical immutable empty string is returned. +The string type is encapsulated. + + <p>SOURCE NOTE: This section is still missing from the report. The +features defined here were taken mostly from r5rs scheme. It is +possible that in the future, klisp only admits immutable strings (like +lua and java), and that operations for contructing strings are moved +to a new type (like Java's StringBuilder/StringBuffer). But for now, +compatibility with r5rs was preferred/simpler. + +<div class="defun"> +&mdash; Applicative: <b>string?</b> (<var>string? . objects</var>)<var><a name="index-string_003f-152"></a></var><br> +<blockquote><p> The primitive type predicate for type string. <code>string?</code> +returns true iff all the objects in <code>objects</code> are of type +string. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string=?</b> (<var>string=? . strings</var>)<var><a name="index-string_003d_003f-153"></a></var><br> +&mdash; Applicative: <b>string&lt;?</b> (<var>string&lt;? . strings</var>)<var><a name="index-string_003c_003f-154"></a></var><br> +&mdash; Applicative: <b>string&lt;=?</b> (<var>string&lt;=? . strings</var>)<var><a name="index-string_003c_003d_003f-155"></a></var><br> +&mdash; Applicative: <b>string&gt;?</b> (<var>string&gt;? . strings</var>)<var><a name="index-string_003e_003f-156"></a></var><br> +&mdash; Applicative: <b>string&gt;=?</b> (<var>string&gt;=? . strings</var>)<var><a name="index-string_003e_003d_003f-157"></a></var><br> +<blockquote><p> These predicates compare any number of strings by their +lexicographic order. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-ci=?</b> (<var>string-ci=? . strings</var>)<var><a name="index-string_002dci_003d_003f-158"></a></var><br> +&mdash; Applicative: <b>string-ci&lt;?</b> (<var>string-ci&lt;? . strings</var>)<var><a name="index-string_002dci_003c_003f-159"></a></var><br> +&mdash; Applicative: <b>string-ci&lt;=?</b> (<var>string-ci&lt;=? . strings</var>)<var><a name="index-string_002dci_003c_003d_003f-160"></a></var><br> +&mdash; Applicative: <b>string-ci&gt;?</b> (<var>string-ci&gt;? . strings</var>)<var><a name="index-string_002dci_003e_003f-161"></a></var><br> +&mdash; Applicative: <b>string-ci&gt;=?</b> (<var>string-ci&gt;=? . strings</var>)<var><a name="index-string_002dci_003e_003d_003f-162"></a></var><br> +<blockquote><p> These predicates convert the strings to lowercase and then compare +them using their lexicographic order. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>make-string</b> (<var>make-string k </var>[<var>char</var>])<var><a name="index-make_002dstring-163"></a></var><br> +<blockquote><p> Applicative <code>make-string</code> constructs and returns a new mutable +string of length <code>k</code>. If <code>char</code> is specified, then all +characters in the returned string are <code>char</code>, otherwise the +content of the string is unspecified. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string</b> (<var>string . chars</var>)<var><a name="index-string-164"></a></var><br> +<blockquote><p> Applicative <code>string</code> contructs and return a new mutable string +composed of the character arguments. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-length</b> (<var>string-length string</var>)<var><a name="index-string_002dlength-165"></a></var><br> +<blockquote><p> Applicative <code>string-length</code> returns the length of +<code>string</code>. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-ref</b> (<var>string-ref string k</var>)<var><a name="index-string_002dref-166"></a></var><br> +<blockquote><p> Applicative <code>string-ref</code> returns the character of <code>string</code> +at position <code>k</code>. If <code>k</code> is out of bounds (i.e. less than +<code>0</code> or greater or equal than <code>(length string)</code>) an error is +signaled. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-set!</b> (<var>string-set! string k char</var>)<var><a name="index-string_002dset_0021-167"></a></var><br> +<blockquote><p> Applicative <code>string-set!</code> replaces the character with index +<code>k</code> in <code>string</code> with character <code>char</code>. If <code>k</code> is +out of bounds, or <code>string</code> is immutable, an error is signaled. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-fill!</b> (<var>string-fill! string char</var>)<var><a name="index-string_002dfill_0021-168"></a></var><br> +<blockquote><p> Applicative <code>string-fill!</code> replaces all the characters in +<code>string</code> with character <code>char</code>. If <code>string</code> is an +immutable string, an error is signaled. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>substring</b> (<var>substring string k1 k2</var>)<var><a name="index-substring-169"></a></var><br> +<blockquote><p> Both <code>k1</code> &amp; <code>k2</code> should be valid indexes in +<code>string</code>. Also it should be the case that <code>k1 &lt;= k2</code>. + + <p>Applicative <code>substring</code> constructs and returns a new immutable +string with length <code>k2 - k1</code>, with the characters from +<code>string</code>, starting at index <code>k1</code> (inclusive) and ending at +index <code>k2</code> (exclusive). +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-append</b> (<var>string-append . strings</var>)<var><a name="index-string_002dappend-170"></a></var><br> +<blockquote><p> Applicative <code>string-append</code> constructs and returns a new +mutable string consisting of the concatenation of all its arguments. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-copy</b> (<var>string-copy string</var>)<var><a name="index-string_002dcopy-171"></a></var><br> +<blockquote><p> Applicative <code>string-copy</code> constructs and returns a new mutable +string with the same length and characters as <code>string</code>. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-&gt;immutable-string</b> (<var>string-&gt;immutable-string string</var>)<var><a name="index-string_002d_003eimmutable_002dstring-172"></a></var><br> +<blockquote><p> Applicative <code>string-&gt;immutable-string</code> constructs and returns a +new immutable string with the same length and characters as +<code>string</code>. +</p></blockquote></div> + +<div class="defun"> +&mdash; Applicative: <b>string-&gt;list</b> (<var>string-&gt;list string</var>)<var><a name="index-string_002d_003elist-173"></a></var><br> +&mdash; Applicative: <b>list-&gt;string</b> (<var>list-&gt;string chars</var>)<var><a name="index-list_002d_003estring-174"></a></var><br> +<blockquote><p> Applicatives <code>string-&gt;list</code> and <code>list-&gt;string</code> convert +between strings and list of characters. The strings returned by +<code>list-&gt;string</code> are mutable. +</p></blockquote></div> + +<!-- TODO add upcase/downcase when added to klisp --> <!-- *-texinfo-*- --> </body></html> diff --git a/manual/klisp.info b/manual/klisp.info @@ -1571,6 +1571,113 @@ File: klisp.info, Node: Strings, Next: Characters, Prev: Numbers, Up: Top 14 Strings ********** +A string is an object that represent a sequence of characters (for now, +only ASCII is supported in klisp, in the future, full UNICODE will be +supported). The external representation of strings consists of a +leading """, the characters of the string and a closing """. Some +characters should be escaped, by preceding them with a "\": in klisp +these are the double quote (""") and the backslash ("\"). In the +future more advanced escape mechanism may be added (like in r7rs-draft +scheme, for escping common ASCII control codes and arbitrary unicode +characters). A string has a length that is fixed at creation time, and +as many characters, indexed from `0' to `length-1'. + + Strings may be mutable or immutable. If an attempt is made to +mutate an immutable string, an error is signaled. Two immutable +strings are "eq?" iff they are "equal?". Two mutable strings are "eq?" +if they were created by the same constructor call. Two mutable strings +are "equal?" iff they are "string=?". For now it is undefined if a +mutable and an immutable strings that are "string=?" are "equal?" or +not. The only exception is the empty string. There is only one empty +string (all empty strings are "eq?" to each other) and it should be +considered immutable. Even if an attempt is made to return a new empty +string (like calling `(string)', the canonical immutable empty string +is returned. The string type is encapsulated. + + SOURCE NOTE: This section is still missing from the report. The +features defined here were taken mostly from r5rs scheme. It is +possible that in the future, klisp only admits immutable strings (like +lua and java), and that operations for contructing strings are moved to +a new type (like Java's StringBuilder/StringBuffer). But for now, +compatibility with r5rs was preferred/simpler. + + -- Applicative: string? (string? . objects) + The primitive type predicate for type string. `string?' returns + true iff all the objects in `objects' are of type string. + + -- Applicative: string=? (string=? . strings) + -- Applicative: string<? (string<? . strings) + -- Applicative: string<=? (string<=? . strings) + -- Applicative: string>? (string>? . strings) + -- Applicative: string>=? (string>=? . strings) + These predicates compare any number of strings by their + lexicographic order. + + -- Applicative: string-ci=? (string-ci=? . strings) + -- Applicative: string-ci<? (string-ci<? . strings) + -- Applicative: string-ci<=? (string-ci<=? . strings) + -- Applicative: string-ci>? (string-ci>? . strings) + -- Applicative: string-ci>=? (string-ci>=? . strings) + These predicates convert the strings to lowercase and then compare + them using their lexicographic order. + + -- Applicative: make-string (make-string k [char]) + Applicative `make-string' constructs and returns a new mutable + string of length `k'. If `char' is specified, then all characters + in the returned string are `char', otherwise the content of the + string is unspecified. + + -- Applicative: string (string . chars) + Applicative `string' contructs and return a new mutable string + composed of the character arguments. + + -- Applicative: string-length (string-length string) + Applicative `string-length' returns the length of `string'. + + -- Applicative: string-ref (string-ref string k) + Applicative `string-ref' returns the character of `string' at + position `k'. If `k' is out of bounds (i.e. less than `0' or + greater or equal than `(length string)') an error is signaled. + + -- Applicative: string-set! (string-set! string k char) + Applicative `string-set!' replaces the character with index `k' in + `string' with character `char'. If `k' is out of bounds, or + `string' is immutable, an error is signaled. + + -- Applicative: string-fill! (string-fill! string char) + Applicative `string-fill!' replaces all the characters in `string' + with character `char'. If `string' is an immutable string, an + error is signaled. + + -- Applicative: substring (substring string k1 k2) + Both `k1' & `k2' should be valid indexes in `string'. Also it + should be the case that `k1 <= k2'. + + Applicative `substring' constructs and returns a new immutable + string with length `k2 - k1', with the characters from `string', + starting at index `k1' (inclusive) and ending at index `k2' + (exclusive). + + -- Applicative: string-append (string-append . strings) + Applicative `string-append' constructs and returns a new mutable + string consisting of the concatenation of all its arguments. + + -- Applicative: string-copy (string-copy string) + Applicative `string-copy' constructs and returns a new mutable + string with the same length and characters as `string'. + + -- Applicative: string->immutable-string (string->immutable-string + string) + Applicative `string->immutable-string' constructs and returns a + new immutable string with the same length and characters as + `string'. + + -- Applicative: string->list (string->list string) + -- Applicative: list->string (list->string chars) + Applicatives `string->list' and `list->string' convert between + strings and list of characters. The strings returned by + `list->string' are mutable. +  File: klisp.info, Node: Characters, Next: Ports, Prev: Strings, Up: Top @@ -2031,6 +2138,7 @@ Index * length: Pairs and lists. (line 191) * list: Pairs and lists. (line 72) * list*: Pairs and lists. (line 78) +* list->string: Strings. (line 109) * list-neighbors: Pairs and lists. (line 228) * list-ref: Pairs and lists. (line 198) * list-tail: Pairs and lists. (line 147) @@ -2041,6 +2149,7 @@ Index * make-kernel-standard-environment: Environments. (line 119) * make-keyed-dynamic-variable: Keyed Variables. (line 21) * make-keyed-static-variable: Keyed Variables. (line 44) +* make-string: Strings. (line 57) * map <1>: Combiners. (line 96) * map: Pairs and lists. (line 169) * member?: Pairs and lists. (line 257) @@ -2072,8 +2181,29 @@ Index * root-continuation: Continuations. (line 104) * set-car!: Pairs and lists. (line 41) * set-cdr!: Pairs and lists. (line 42) +* string: Strings. (line 63) +* string->immutable-string: Strings. (line 103) +* string->list: Strings. (line 108) * string->symbol: Symbols. (line 20) +* string-append: Strings. (line 94) +* string-ci<=?: Strings. (line 51) +* string-ci<?: Strings. (line 50) +* string-ci=?: Strings. (line 49) +* string-ci>=?: Strings. (line 53) +* string-ci>?: Strings. (line 52) +* string-copy: Strings. (line 98) +* string-fill!: Strings. (line 80) +* string-length: Strings. (line 67) +* string-ref: Strings. (line 70) +* string-set!: Strings. (line 75) +* string<=?: Strings. (line 43) +* string<?: Strings. (line 42) +* string=?: Strings. (line 41) +* string>=?: Strings. (line 45) +* string>?: Strings. (line 44) +* string?: Strings. (line 37) * strings: Strings. (line 6) +* substring: Strings. (line 85) * symbol->string: Symbols. (line 16) * symbol?: Symbols. (line 12) * symbols: Symbols. (line 6) @@ -2109,8 +2239,8 @@ Node: Promises65437 Node: Keyed Variables69360 Node: Numbers72131 Node: Strings72240 -Node: Characters72344 -Node: Ports75054 -Node: Index86339 +Node: Characters77587 +Node: Ports80297 +Node: Index91582  End Tag Table diff --git a/manual/src/strings.texi b/manual/src/strings.texi @@ -6,3 +6,131 @@ @chapter Strings @cindex strings + + A string is an object that represent a sequence of characters (for +now, only ASCII is supported in klisp, in the future, full UNICODE +will be supported). The external representation of strings consists +of a leading ``"'', the characters of the string and a closing ``"''. +Some characters should be escaped, by preceding them with a ``\'': in +klisp these are the double quote (``"'') and the backslash (``\''). +In the future more advanced escape mechanism may be added (like in +r7rs-draft scheme, for escping common ASCII control codes and +arbitrary unicode characters). A string has a length that is fixed at +creation time, and as many characters, indexed from @code{0} to +@code{length-1}. + + Strings may be mutable or immutable. If an attempt is made to +mutate an immutable string, an error is signaled. Two immutable +strings are ``eq?'' iff they are ``equal?''. Two mutable strings are +``eq?'' if they were created by the same constructor call. Two +mutable strings are ``equal?'' iff they are ``string=?''. For now it +is undefined if a mutable and an immutable strings that are +``string=?'' are ``equal?'' or not. The only exception is the empty +string. There is only one empty string (all empty strings are ``eq?'' +to each other) and it should be considered immutable. Even if an +attempt is made to return a new empty string (like calling +@code{(string)}, the canonical immutable empty string is returned. +The string type is encapsulated. + +SOURCE NOTE: This section is still missing from the report. The +features defined here were taken mostly from r5rs scheme. It is +possible that in the future, klisp only admits immutable strings (like +lua and java), and that operations for contructing strings are moved +to a new type (like Java's StringBuilder/StringBuffer). But for now, +compatibility with r5rs was preferred/simpler. + +@deffn Applicative string? (string? . objects) + The primitive type predicate for type string. @code{string?} +returns true iff all the objects in @code{objects} are of type +string. +@end deffn + +@deffn Applicative string=? (string=? . strings) +@deffnx Applicative string<? (string<? . strings) +@deffnx Applicative string<=? (string<=? . strings) +@deffnx Applicative string>? (string>? . strings) +@deffnx Applicative string>=? (string>=? . strings) + These predicates compare any number of strings by their +lexicographic order. +@end deffn + +@deffn Applicative string-ci=? (string-ci=? . strings) +@deffnx Applicative string-ci<? (string-ci<? . strings) +@deffnx Applicative string-ci<=? (string-ci<=? . strings) +@deffnx Applicative string-ci>? (string-ci>? . strings) +@deffnx Applicative string-ci>=? (string-ci>=? . strings) + These predicates convert the strings to lowercase and then compare +them using their lexicographic order. +@end deffn + +@deffn Applicative make-string (make-string k [char]) + Applicative @code{make-string} constructs and returns a new mutable +string of length @code{k}. If @code{char} is specified, then all +characters in the returned string are @code{char}, otherwise the +content of the string is unspecified. +@end deffn + +@deffn Applicative string (string . chars) + Applicative @code{string} contructs and return a new mutable string +composed of the character arguments. +@end deffn + +@deffn Applicative string-length (string-length string) + Applicative @code{string-length} returns the length of +@code{string}. +@end deffn + +@deffn Applicative string-ref (string-ref string k) + Applicative @code{string-ref} returns the character of @code{string} +at position @code{k}. If @code{k} is out of bounds (i.e. less than +@code{0} or greater or equal than @code{(length string)}) an error is +signaled. +@end deffn + +@deffn Applicative string-set! (string-set! string k char) + Applicative @code{string-set!} replaces the character with index +@code{k} in @code{string} with character @code{char}. If @code{k} is +out of bounds, or @code{string} is immutable, an error is signaled. +@end deffn + +@deffn Applicative string-fill! (string-fill! string char) + Applicative @code{string-fill!} replaces all the characters in +@code{string} with character @code{char}. If @code{string} is an +immutable string, an error is signaled. +@end deffn + +@deffn Applicative substring (substring string k1 k2) + Both @code{k1} & @code{k2} should be valid indexes in +@code{string}. Also it should be the case that @code{k1 <= k2}. + + Applicative @code{substring} constructs and returns a new immutable +string with length @code{k2 - k1}, with the characters from +@code{string}, starting at index @code{k1} (inclusive) and ending at +index @code{k2} (exclusive). +@end deffn + +@deffn Applicative string-append (string-append . strings) + Applicative @code{string-append} constructs and returns a new +mutable string consisting of the concatenation of all its arguments. +@end deffn + +@deffn Applicative string-copy (string-copy string) + Applicative @code{string-copy} constructs and returns a new mutable +string with the same length and characters as @code{string}. +@end deffn + +@deffn Applicative string->immutable-string (string->immutable-string string) + Applicative @code{string->immutable-string} constructs and returns a +new immutable string with the same length and characters as +@code{string}. +@end deffn + +@deffn Applicative string->list (string->list string) +@deffnx Applicative list->string (list->string chars) + Applicatives @code{string->list} and @code{list->string} convert +between strings and list of characters. The strings returned by +@code{list->string} are mutable. +@end deffn + +@c TODO add upcase/downcase when added to klisp + diff --git a/src/kgstrings.c b/src/kgstrings.c @@ -483,7 +483,10 @@ void kinit_strings_ground_env(klisp_State *K) string_to_immutable_string, 0); /* TODO: add string-immutable? or general immutable? */ + /* TODO: add string-upcase and string-downcase like in r7rs-draft */ /* 13.2.10? string-fill! */ add_applicative(K, ground_env, "string-fill!", string_fillS, 0); + + }