| 1 |
<!DOCTYPE html> |
| 2 |
<html><head><title>Appendix 3: XLISP: An Object-oriented Lisp</title> |
| 3 |
<link rel="stylesheet" type="text/css" href="nyquiststyle.css"> |
| 4 |
<link rel="icon" href="nyquist-icon.png" /> |
| 5 |
<link rel="shortcut icon" href="nyquist-icon.png" /> |
| 6 |
</head> |
| 7 |
<body bgcolor="ffffff"> |
| 8 |
<a href = "part18.html">Previous Section</a> | <a href = "indx.html">Next Section (Index)</a> | <a href = "title.html#toc">Table of Contents</a> | <a href = "title.html">Title Page</a> |
| 9 |
<hr> |
| 10 |
<a name = "224"><h2>Appendix 3: XLISP: An Object-oriented Lisp</h2></a><blockquote><b>Version 2.0</b> |
| 11 |
<p>February 6, 1988</p> |
| 12 |
|
| 13 |
<p>by<br> |
| 14 |
|
| 15 |
<b>David Michael Betz</b><br> |
| 16 |
|
| 17 |
127 Taylor Road<br> |
| 18 |
|
| 19 |
Peterborough, NH 03458</p> |
| 20 |
|
| 21 |
<p>Copyright (c) 1988, by David Michael Betz<br> |
| 22 |
|
| 23 |
All Rights Reserved<br> |
| 24 |
|
| 25 |
Permission is granted for unrestricted non-commercial use<br> |
| 26 |
|
| 27 |
</blockquote> |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
<a name = "225"><h3>Introduction</h3></a></p> |
| 35 |
|
| 36 |
<p> XLISP is an experimental programming language combining some of |
| 37 |
the features of Common Lisp with an object-oriented extension |
| 38 |
capability. It was implemented to allow experimentation with |
| 39 |
object-oriented programming on small computers.</p> |
| 40 |
|
| 41 |
<p> Implementations of XLISP run on virtually every operating system. |
| 42 |
XLISP is completely written in the programming language |
| 43 |
C and is easily extended with user written built-in functions |
| 44 |
and classes. It is available in source form to non-commercial |
| 45 |
users.</p> |
| 46 |
|
| 47 |
<p> Many Common Lisp functions are built into XLISP. In addition, |
| 48 |
XLISP defines the objects Object and Class as primitives. |
| 49 |
Object is the only class that has no superclass and hence is |
| 50 |
the root of the class hierarchy tree. Class is the class of |
| 51 |
which all classes are instances (it is the only object that is |
| 52 |
an instance of itself).</p> |
| 53 |
|
| 54 |
<p> This document is a brief description of XLISP. It assumes some |
| 55 |
knowledge of LISP and some understanding of the concepts of |
| 56 |
object-oriented programming.</p> |
| 57 |
|
| 58 |
<p> I recommend the book <i>Lisp</i> by Winston and Horn and published by |
| 59 |
Addison Wesley for learning Lisp. The first edition of this |
| 60 |
book is based on MacLisp and the second edition is based on |
| 61 |
Common Lisp. </p> |
| 62 |
|
| 63 |
<p> You will probably also need a copy of <i>Common Lisp: The |
| 64 |
Language</i> by Guy L. Steele, Jr., published by Digital Press to |
| 65 |
use as a reference for some of the Common Lisp functions that |
| 66 |
are described only briefly in this document.</p> |
| 67 |
|
| 68 |
<p> <a name = "226"><h3>A Note From The Author</h3></a></p> |
| 69 |
|
| 70 |
<p> If you have any problems with XLISP, feel free to contact me [me being David Betz - RBD] for |
| 71 |
help or advice. Please remember that since XLISP is available |
| 72 |
in source form in a high level language, many users [e.g. that Dannenberg fellow - RBD] have been |
| 73 |
making versions available on a variety of machines. If you call |
| 74 |
to report a problem with a specific version, I may not be able |
| 75 |
to help you if that version runs on a machine to which I don't |
| 76 |
have access. Please have the version number of the version that |
| 77 |
you are running readily accessible before calling me.</p> |
| 78 |
|
| 79 |
<p> If you find a bug in XLISP, first try to fix the bug yourself |
| 80 |
using the source code provided. If you are successful in fixing |
| 81 |
the bug, send the bug report along with the fix to me. If you |
| 82 |
don't have access to a C compiler or are unable to fix a bug, |
| 83 |
please send the bug report to me and I'll try to fix it.</p> |
| 84 |
|
| 85 |
<p> Any suggestions for improvements will be welcomed. Feel free to |
| 86 |
extend the language in whatever way suits your needs. However, |
| 87 |
PLEASE DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME |
| 88 |
FIRST!! I would like to be the clearing house for new features |
| 89 |
added to XLISP. If you want to add features for your own |
| 90 |
personal use, go ahead. But, if you want to distribute your |
| 91 |
enhanced version, contact me first. Please remember that the |
| 92 |
goal of XLISP is to provide a language to learn and experiment |
| 93 |
with LISP and object-oriented programming on small computers. I |
| 94 |
don't want it to get so big that it requires megabytes of memory |
| 95 |
to run.</p> |
| 96 |
|
| 97 |
<p> <a name = "227"><h3>XLISP Command Loop</h3></a><a name="index1466"></a><a name="index1467"></a></p> |
| 98 |
|
| 99 |
<p> When XLISP is started, it first tries to load the workspace |
| 100 |
<code>xlisp.wks</code> from the current directory. If that file doesn't |
| 101 |
exist, XLISP builds an initial workspace, empty except for the |
| 102 |
built-in functions and symbols.</p> |
| 103 |
|
| 104 |
<p> Then XLISP attempts to load <code>init.lsp</code> from the current |
| 105 |
directory. It then loads any files named as parameters on the |
| 106 |
command line (after appending <code>.lsp</code> to their names).</p> |
| 107 |
|
| 108 |
<p> XLISP then issues the following prompt: |
| 109 |
</p> |
| 110 |
<pre> |
| 111 |
> |
| 112 |
</pre> |
| 113 |
|
| 114 |
<p> |
| 115 |
This indicates that XLISP is waiting for an expression to be |
| 116 |
typed.</p> |
| 117 |
|
| 118 |
<p> When a complete expression has been entered, XLISP attempts to |
| 119 |
evaluate that expression. If the expression evaluates |
| 120 |
successfully, XLISP prints the result and then returns to the |
| 121 |
initial prompt waiting for another expression to be typed.</p> |
| 122 |
|
| 123 |
<p> <a name = "228"><h3>Special Characters</h3></a><a name="index1468"></a></p> |
| 124 |
|
| 125 |
<p> When XLISP is running from a console, some control characters invoke operations: |
| 126 |
<ul> |
| 127 |
<li> |
| 128 |
Backspace and Delete characters erase the previous character on the input line (if any).</li> |
| 129 |
<li>Control-U erases the entire input line. </li> |
| 130 |
<li>Control-C executes the TOP-LEVEL function.</li> |
| 131 |
<li>Control-G executes the CLEAN-UP function.</li> |
| 132 |
<li>Control-P executes the CONTINUE function.</li> |
| 133 |
<li>Control-B stops execution and enters the break command loop. Execution can be continued by typing Control-P or (CONTINUE).</li> |
| 134 |
<li>Control-E turns on character echoing (Linux and Mac OS X only).</li> |
| 135 |
<li>Control-F turns off character echoing (Linux and Mac OS X only).</li> |
| 136 |
<li>Control-T evaluates the INFO function. |
| 137 |
</li></ul></p> |
| 138 |
|
| 139 |
<p> <a name = "229"><h3>Break Command Loop</h3></a><a name="index1469"></a></p> |
| 140 |
|
| 141 |
<p> When XLISP encounters an error while evaluating an expression, |
| 142 |
it attempts to handle the error in the following way:</p> |
| 143 |
|
| 144 |
<p> If the symbol <code>*breakenable*<a name="index1470"></a></code> is |
| 145 |
true, the message corresponding to the error is printed. If |
| 146 |
the error is correctable, the correction message is printed.</p> |
| 147 |
|
| 148 |
<p> If the symbol <code>*tracenable*<a name="index1471"></a></code> is true, a trace back is printed. |
| 149 |
The number of entries printed depends on the value of the symbol |
| 150 |
<code>*tracelimit*<a name="index1472"></a></code>. If this symbol is set to something other than a |
| 151 |
number, the entire trace back stack is printed.</p> |
| 152 |
|
| 153 |
<p> XLISP then enters a read/eval/print loop to allow the user to |
| 154 |
examine the state of the interpreter in the context of the |
| 155 |
error. This loop differs from the normal top-level |
| 156 |
read/eval/print loop in that if the user invokes the function |
| 157 |
<code>continue</code>, XLISP will continue from a correctable error. If |
| 158 |
the user invokes the function <code>clean-up</code>, XLISP will abort the |
| 159 |
break loop and return to the top level or the next lower |
| 160 |
numbered break loop. When in a break loop, XLISP prefixes the |
| 161 |
break level to the normal prompt.</p> |
| 162 |
|
| 163 |
<p> If the symbol <code>*breakenable*<a name="index1473"></a></code> is <code>nil</code>, XLISP looks for a |
| 164 |
surrounding errset function. If one is found, XLISP examines |
| 165 |
the value of the print flag. If this flag is true, the error |
| 166 |
message is printed. In any case, XLISP causes the errset |
| 167 |
function call to return <code>nil</code>.</p> |
| 168 |
|
| 169 |
<p> If there is no surrounding errset function, XLISP prints the |
| 170 |
error message and returns to the top level.</p> |
| 171 |
|
| 172 |
<p> <a name = "230"><h3>Data Types</h3></a><a name="index1474"></a><a name="index1475"></a></p> |
| 173 |
|
| 174 |
<p> There are several different data types available to XLISP |
| 175 |
programmers.</p> |
| 176 |
<ul> |
| 177 |
<li> |
| 178 |
lists - are linked lists of <code>cons</code> cells, where a <code>cons</code> cell is |
| 179 |
a pair of references called the <code>car</code> or <code>head</code> and <code>cdr</code> or |
| 180 |
<code>tail</code>. |
| 181 |
The empty list is the null reference denoted by <code>nil</code><a name="index1476"></a>. |
| 182 |
(There is no |
| 183 |
<code>cons</code> cell.) A list of 1 element is a <code>cons</code> cell |
| 184 |
whose <code>car</code> is the element and whose <code>cdr</code> is a list of no elements, |
| 185 |
i.e. <code>nil</code>. A list of 2 elements is a <code>cons</code> cell whose <code>car</code> |
| 186 |
is the first element and whose <code>cdr</code> is a list containing the second |
| 187 |
element, and so on.</li> |
| 188 |
<li>symbols - unique strings that serve as names of variables and names of functions. All symbols are in a global symbol table.</li> |
| 189 |
<li>strings - non-unique, immutable character strings.</li> |
| 190 |
<li>integers</li> |
| 191 |
<li>characters - note that characters are not strings.</li> |
| 192 |
<li>floats</li> |
| 193 |
<li>objects</li> |
| 194 |
<li>arrays</li> |
| 195 |
<li>streams</li> |
| 196 |
<li>subrs (built-in functions)</li> |
| 197 |
<li>fsubrs (special forms)</li> |
| 198 |
<li>closures (user defined functions) |
| 199 |
</li></ul><a name = "231"><h3>The Evaluator</h3></a><a name="index1477"></a><a name="index1478"></a> |
| 200 |
<p> The process of evaluation in XLISP: |
| 201 |
<ul> |
| 202 |
<li> |
| 203 |
Strings, integers, characters, floats, objects, arrays, streams, |
| 204 |
subrs, fsubrs and closures evaluate to themselves.</li> |
| 205 |
<li> Symbols act as variables and are evaluated by retrieving the |
| 206 |
value associated with their current binding.</li> |
| 207 |
<li> Lists are evaluated by examining the first element of the list |
| 208 |
and then taking one of the following actions: |
| 209 |
<ul> |
| 210 |
<li> |
| 211 |
If it is a symbol, the functional binding of the symbol is |
| 212 |
retrieved.</li> |
| 213 |
<li> If it is a lambda expression, a closure is constructed for |
| 214 |
the function described by the lambda expression.</li> |
| 215 |
<li> If it is a subr, fsubr or closure, it stands for itself.</li> |
| 216 |
<li> Any other value is an error. |
| 217 |
</li></ul> |
| 218 |
Then, the value produced by the previous step is examined: |
| 219 |
<ul> |
| 220 |
<li> |
| 221 |
If it is a subr or closure, the remaining list elements are |
| 222 |
evaluated and the subr or closure is called with these |
| 223 |
evaluated expressions as arguments.</li> |
| 224 |
<li> If it is an fsubr, the fsubr is called using the remaining |
| 225 |
list elements as arguments (unevaluated).</li> |
| 226 |
<li> If it is a macro, the macro is expanded using the remaining |
| 227 |
list elements as arguments (unevaluated). The macro |
| 228 |
expansion is then evaluated in place of the original macro |
| 229 |
call. |
| 230 |
</li></ul> |
| 231 |
</li></ul></p> |
| 232 |
<a name = "232"><h3>Lexical Conventions</h3></a><a name="index1479"></a><a name="index1480"></a> |
| 233 |
<p> The following conventions must be followed when entering XLISP |
| 234 |
programs:</p> |
| 235 |
|
| 236 |
<p> Comments in XLISP code begin with a semi-colon character and |
| 237 |
continue to the end of the line.</p> |
| 238 |
|
| 239 |
<p> Symbol names in XLISP can consist of any sequence of non-blank |
| 240 |
printable characters except the following: |
| 241 |
</p> |
| 242 |
<pre> |
| 243 |
( ) ' ` , " ; |
| 244 |
</pre> |
| 245 |
|
| 246 |
<p> |
| 247 |
<a name="index1481"></a>Uppercase and lowercase characters are |
| 248 |
not distinguished within |
| 249 |
symbol names. All lowercase characters are mapped to uppercase |
| 250 |
on input.</p> |
| 251 |
|
| 252 |
<p> Integer literals consist of a sequence of digits optionally |
| 253 |
beginning with a <code>+</code> or <code>-</code>. The range of values an integer can |
| 254 |
represent is limited by the size of a C <code>long</code> on the machine on |
| 255 |
which XLISP is running.</p> |
| 256 |
|
| 257 |
<p> Floating point literals consist of a sequence of digits |
| 258 |
optionally beginning with a <code>+</code> or <code>-</code> and including an embedded |
| 259 |
decimal point. The range of values a floating point number can |
| 260 |
represent is limited by the size of a C <code>float</code> (<code>double</code> on |
| 261 |
machines with 32 bit addresses) on the machine on which XLISP is |
| 262 |
running.</p> |
| 263 |
|
| 264 |
<p> Literal strings are sequences of characters surrounded by double |
| 265 |
quotes. Within quoted strings the “<code>\</code>” character is used to |
| 266 |
allow non-printable characters to be included. The codes |
| 267 |
recognized are: |
| 268 |
<ul> |
| 269 |
<li> |
| 270 |
<code>\\</code> means the character “<code>\</code>”</li> |
| 271 |
<li><code>\n</code> means newline</li> |
| 272 |
<li><code>\t</code> means tab</li> |
| 273 |
<li><code>\r</code> means return</li> |
| 274 |
<li><code>\f</code> means form feed</li> |
| 275 |
<li><code>\nnn</code> means the character whose octal code is nnn |
| 276 |
</li></ul></p> |
| 277 |
<a name = "233"><h3>Readtables</h3></a><a name="index1482"></a> |
| 278 |
<p> The behavior of the reader is controlled by a data structure |
| 279 |
called a <i>readtable</i>. The reader uses the symbol <code>*readtable*<a name="index1483"></a></code> to |
| 280 |
locate the current readtable. This table controls the |
| 281 |
interpretation of input characters. It is an array with 128 |
| 282 |
entries, one for each of the ASCII character codes. Each entry |
| 283 |
contains one of the following things: |
| 284 |
<ul> |
| 285 |
<li> |
| 286 |
<code>NIL</code> – Indicating an invalid character</li> |
| 287 |
<li> <code>:CONSTITUENT</code> – Indicating a symbol constituent</li> |
| 288 |
<li> <code>:WHITE-SPACE</code> – Indicating a whitespace character</li> |
| 289 |
<li> <code>(:TMACRO . <i>fun</i>)</code> – Terminating readmacro</li> |
| 290 |
<li> <code>(:NMACRO . <i>fun</i>)</code> – Non-terminating readmacro</li> |
| 291 |
<li> <code>:SESCAPE</code> – Single escape character ('\')</li> |
| 292 |
<li> <code>:MESCAPE</code> – Multiple escape character ('|') |
| 293 |
</li></ul></p> |
| 294 |
|
| 295 |
<p> In the case of <code>:TMACRO</code> and <code>:NMACRO</code>, the <i>fun</i> component is a |
| 296 |
function. This can either be a built-in readmacro function or a |
| 297 |
lambda expression. The function should take two parameters. |
| 298 |
The first is the input stream and the second is the character |
| 299 |
that caused the invocation of the readmacro. The readmacro |
| 300 |
function should return <code>NIL</code> to indicate that the character should |
| 301 |
be treated as white space or a value consed with <code>NIL</code> to indicate |
| 302 |
that the readmacro should be treated as an occurence of the |
| 303 |
specified value. Of course, the readmacro code is free to read |
| 304 |
additional characters from the input stream.</p> |
| 305 |
|
| 306 |
<p> XLISP defines several useful read macros<a name="index1484"></a>: |
| 307 |
<ul> |
| 308 |
<li> |
| 309 |
<code>'</code><i><expr></i> == <code>(quote</code> <i><expr></i><code>)</code></li> |
| 310 |
<li> <code>#'</code><i><expr></i> == <code>(function</code> <i><expr></i><code>)</code></li> |
| 311 |
<li> <code>#(</code><i><expr></i>...<code>)</code> == an array of the specified expressions</li> |
| 312 |
<li> <code>#x</code><i><hdigits></i> == a hexadecimal number (0-9,A-F)</li> |
| 313 |
<li> <code>#o</code><i><odigits></i> == an octal number (0-7)</li> |
| 314 |
<li> <code>#b</code><i><bdigits></i> == a binary number (0-1)</li> |
| 315 |
<li> <code>#\</code><i><char></i> == literal of type character</li> |
| 316 |
<li> <code>#\Newline</code> == newline character</li> |
| 317 |
<li> <code>#\Space</code> == space character</li> |
| 318 |
<li> <code>#\Tab</code> == tab character</li> |
| 319 |
<li> <code>#|</code> ... <code>|#</code> == a comment</li> |
| 320 |
<li> <code>#:</code><i><symbol></i> == an uninterned symbol</li> |
| 321 |
<li> <code>`</code><i><expr></i> == <code>(backquote</code> <i><expr></i><code>)</code></li> |
| 322 |
<li> <code>,</code><i><expr></i> == <code>(comma</code> <i><expr></i><code>)</code></li> |
| 323 |
<li> <code>,@</code><i><expr></i> == <code>(comma-at</code> <i><expr></i><code>)</code></li></ul> |
| 324 |
<a name = "234"><h3>Lambda Lists</h3></a><a name="index1485"></a></p> |
| 325 |
|
| 326 |
<p> There are several forms in XLISP that require that a “lambda |
| 327 |
list” be specified. A lambda list is a definition of the |
| 328 |
arguments accepted by a function. There are four different |
| 329 |
types of arguments.</p> |
| 330 |
|
| 331 |
<p> The lambda list starts with required arguments. Required |
| 332 |
arguments must be specified in every call to the function.</p> |
| 333 |
|
| 334 |
<p> The required arguments are followed by the <code>&optional</code> arguments. |
| 335 |
Optional arguments may be provided or omitted in a call. An |
| 336 |
initialization expression may be specified to provide a default |
| 337 |
value for an <code>&optional</code> argument if it is omitted from a call. |
| 338 |
If no initialization expression is specified, an omitted |
| 339 |
argument is initialized to <code>NIL</code>. It is also possible to provide |
| 340 |
the name of a <code>supplied-p</code> variable that can be used to |
| 341 |
determine if a call provided a value for the argument or if the |
| 342 |
initialization expression was used. If specified, the supplied- |
| 343 |
p variable will be bound to T if a value was specified in the |
| 344 |
call and <code>NIL</code> if the default value was used.</p> |
| 345 |
|
| 346 |
<p> The <code>&optional</code> arguments are followed by the <code>&rest</code> argument. The |
| 347 |
<code>&rest</code> argument gets bound to the remainder of the argument list |
| 348 |
after the required and <code>&optional</code> arguments have been removed.</p> |
| 349 |
|
| 350 |
<p> The <code>&rest</code> argument is followed by the <code>&key</code> arguments. When a |
| 351 |
keyword argument is passed to a function, a pair of values |
| 352 |
appears in the argument list. The first expression in the pair |
| 353 |
should evaluate to a keyword symbol (a symbol that begins with a |
| 354 |
“<code>:</code>”). The value of the second expression is the value of the |
| 355 |
keyword argument. Like <code>&optional</code> arguments, <code>&key</code> arguments can |
| 356 |
have initialization expressions and supplied-p variables. In |
| 357 |
addition, it is possible to specify the keyword to be used in a |
| 358 |
function call. If no keyword is specified, the keyword obtained |
| 359 |
by adding a “<code>:</code>” to the beginning of the keyword argument symbol |
| 360 |
is used. In other words, if the keyword argument symbol is |
| 361 |
<code>foo</code>, the keyword will be <code>:foo</code>.</p> |
| 362 |
|
| 363 |
<p> The <code>&key</code> arguments are followed by the <code>&aux</code> variables. These |
| 364 |
are local variables that are bound during the evaluation of the |
| 365 |
function body. It is possible to have initialization |
| 366 |
expressions for the <code>&aux</code> variables.</p> |
| 367 |
|
| 368 |
<p> Here is the complete syntax for lambda lists: |
| 369 |
<blockquote> |
| 370 |
(<i>rarg</i>...<br> |
| 371 |
|
| 372 |
[<code>&optional</code> [<i>oarg</i> | (<i>oarg</i> [<i>init</i> [<i>svar</i>]])]...]<br> |
| 373 |
|
| 374 |
[<code>&rest</code> <i>rarg</i>]<br> |
| 375 |
|
| 376 |
[<code>&key</code><br> |
| 377 |
|
| 378 |
[<i>karg</i> | ([<i>karg</i> | (<i>key</i> <i>karg</i>)] [<i>init</i> [<i>svar</i>]])]...<br> |
| 379 |
|
| 380 |
<code>&allow</code>-other-keys]<br> |
| 381 |
|
| 382 |
[<code>&aux</code><br> |
| 383 |
|
| 384 |
[<i>aux</i> | (<i>aux</i> [<i>init</i>])]...])</p> |
| 385 |
|
| 386 |
<p> where:</p> |
| 387 |
|
| 388 |
<p> <i>rarg</i> is a required argument symbol<br> |
| 389 |
|
| 390 |
<i>oarg</i> is an <code>&optional</code> argument symbol<br> |
| 391 |
|
| 392 |
<i>rarg</i> is the <code>&rest</code> argument symbol<br> |
| 393 |
|
| 394 |
<i>karg</i> is a <code>&key</code> argument symbol<br> |
| 395 |
|
| 396 |
<i>key</i> is a keyword symbol<br> |
| 397 |
|
| 398 |
<i>aux</i> is an auxiliary variable symbol<br> |
| 399 |
|
| 400 |
<i>init</i> is an initialization expression<br> |
| 401 |
|
| 402 |
<i>svar</i> is a supplied-p variable symbol </blockquote> |
| 403 |
<a name = "235"><h3>Objects</h3></a><a name="index1486"></a></p> |
| 404 |
|
| 405 |
<p> Definitions: |
| 406 |
<ul> |
| 407 |
<li> |
| 408 |
selector – a symbol used to select an appropriate method</li> |
| 409 |
<li>message – a selector and a list of actual arguments</li> |
| 410 |
<li>method – the code that implements a message |
| 411 |
</li></ul> |
| 412 |
Since XLISP was created to provide a simple basis for |
| 413 |
experimenting with object-oriented programming, one of the |
| 414 |
primitive data types included is <i>object</i>. In XLISP, an object |
| 415 |
consists of a data structure containing a pointer to the |
| 416 |
object's class as well as an array containing the values of the |
| 417 |
object's instance variables.</p> |
| 418 |
|
| 419 |
<p> Officially, there is no way to see inside an object (look at the |
| 420 |
values of its instance variables). The only way to communicate |
| 421 |
with an object is by sending it a message.</p> |
| 422 |
|
| 423 |
<p> You can send a message to an object using the <code>send</code> function. |
| 424 |
This function takes the object as its first argument, the |
| 425 |
message selector as its second argument (which must be a symbol) |
| 426 |
and the message arguments as its remaining arguments.</p> |
| 427 |
|
| 428 |
<p> The <code>send</code> function determines the class of the receiving object |
| 429 |
and attempts to find a method corresponding to the message |
| 430 |
selector in the set of messages defined for that class. If the |
| 431 |
message is not found in the object's class and the class has a |
| 432 |
super-class, the search continues by looking at the messages |
| 433 |
defined for the super-class. This process continues from one |
| 434 |
super-class to the next until a method for the message is found. |
| 435 |
If no method is found, an error occurs.</p> |
| 436 |
|
| 437 |
<p> When a method is found, the evaluator binds the receiving object |
| 438 |
to the symbol <code>self</code> and evaluates the method using the |
| 439 |
remaining elements of the original list as arguments to the |
| 440 |
method. These arguments are always evaluated prior to being |
| 441 |
bound to their corresponding formal arguments. The result of |
| 442 |
evaluating the method becomes the result of the expression.</p> |
| 443 |
|
| 444 |
<p> Within the body of a method, a message can be sent to the current |
| 445 |
object by calling the <code>(send self ...)</code>. The method lookup |
| 446 |
starts with the object's class regardless of the class containing |
| 447 |
the current method.</p> |
| 448 |
|
| 449 |
<p> Sometimes it is desirable to invoke a general method in a superclass |
| 450 |
even when it is overridden by a more specific method in a subclass. |
| 451 |
This can be accomplished by calling <code>send-super</code>, which begins |
| 452 |
the method lookup in the superclass of the class defining the current |
| 453 |
method rather than in the class of the current object.</p> |
| 454 |
|
| 455 |
<p> The <code>send-super</code> function takes a selector as its first argument |
| 456 |
(which must be a symbol) and the message arguments as its remaining |
| 457 |
arguments. Notice that <code>send-super</code> can only be sent from within |
| 458 |
a method, and the target of the message is always the current object |
| 459 |
(<code>self</code>). <code>(send-super ...)</code> is similar to |
| 460 |
<code>(send self ...)</code> except that method lookup begins in the |
| 461 |
superclass of the class containing the current method |
| 462 |
rather than the class of the current object.</p> |
| 463 |
<a name = "236"><h3>The “Object” Class</h3></a><a name="index1487"></a><code>Object</code><a name="index1488"></a> – the top of the class hierarchy. |
| 464 |
<p>Messages: |
| 465 |
<div style="padding-left: 0em;"> |
| 466 |
<code>:show<a name="index1489"></a></code> – show an object's instance variables. |
| 467 |
</div><div style="padding-left: 2em;"> |
| 468 |
returns – the object<br> |
| 469 |
|
| 470 |
</div> |
| 471 |
<br> |
| 472 |
<code>:class<a name="index1490"></a></code> – return the class of an object |
| 473 |
</div><div style="padding-left: 2em;"> |
| 474 |
returns – the class of the object<br> |
| 475 |
|
| 476 |
</div> |
| 477 |
<br> |
| 478 |
<code>:isa<a name="index1491"></a></code> <i>class</i> – test if object inherits from class |
| 479 |
</div><div style="padding-left: 2em;"> |
| 480 |
returns – <code>t</code> if object is an instance of <i>class</i> or a subclass of <i>class</i>, otherwise <code>nil</code><br> |
| 481 |
|
| 482 |
</div> |
| 483 |
<br> |
| 484 |
<code>:isnew<a name="index1492"></a></code> – the default object initialization routine |
| 485 |
</div><div style="padding-left: 2em;"> |
| 486 |
returns – the object<br> |
| 487 |
|
| 488 |
</div> |
| 489 |
</div> |
| 490 |
</p> |
| 491 |
<a name = "237"><h3>The “Class” Class</h3></a><a name="index1493"></a><code>Class<a name="index1494"></a></code> – class of all object classes (including itself) |
| 492 |
<p> Messages: |
| 493 |
<div style="padding-left: 0em;"> |
| 494 |
<code>:new<a name="index1495"></a></code> – create a new instance of a class |
| 495 |
</div><div style="padding-left: 2em;"> |
| 496 |
returns – the new class object<br> |
| 497 |
|
| 498 |
</div> |
| 499 |
<br> |
| 500 |
<code>:isnew<a name="index1496"></a></code> <i>ivars</i> [<i>cvars</i> [<i>super</i>]] – initialize a new class |
| 501 |
</div><div style="padding-left: 2em;"> |
| 502 |
<i>ivars</i> – the list of instance variable symbols</div> |
| 503 |
<div style="padding-left: 2em;"> <i>cvars</i> – the list of class variable symbols</div> |
| 504 |
<div style="padding-left: 2em;"> <i>super</i> – the superclass (default is object)</div> |
| 505 |
<div style="padding-left: 2em;"> returns – the new class object<br> |
| 506 |
|
| 507 |
</div> |
| 508 |
<br> |
| 509 |
<code>:answer<a name="index1497"></a></code> <i>msg</i> <i>fargs</i> <i>code</i> – add a message to a class |
| 510 |
</div><div style="padding-left: 2em;"> |
| 511 |
<i>msg</i> – the message symbol</div> |
| 512 |
<div style="padding-left: 2em;"> <i>fargs</i> – the formal argument list (lambda list)</div> |
| 513 |
<div style="padding-left: 2em;"> <i>code</i> – a list of executable expressions</div> |
| 514 |
<div style="padding-left: 2em;"> returns – the object<br> |
| 515 |
|
| 516 |
</div> |
| 517 |
|
| 518 |
</div> |
| 519 |
</p> |
| 520 |
|
| 521 |
<p> When a new instance of a class is created by sending the message |
| 522 |
<code>:new</code> to an existing class, the message <code>:isnew</code> followed by |
| 523 |
whatever parameters were passed to the <code>:new</code> message is sent to |
| 524 |
the newly created object.</p> |
| 525 |
|
| 526 |
<p> When a new class is created by sending the <code>:new</code> message to the |
| 527 |
object <code>Class</code>, an optional parameter may be specified |
| 528 |
indicating the superclass of the new class. If this parameter |
| 529 |
is omitted, the new class will be a subclass of <code>Object</code>. A |
| 530 |
class inherits all instance variables, class variables, and |
| 531 |
methods from its super-class.</p> |
| 532 |
<a name = "238"><h3>Profiling</h3></a><a name="index1498"></a> |
| 533 |
<p>The Xlisp 2.0 release has been extended with a profiling facility, which counts how many times and where <code>eval</code> is executed. A separate count is maintained for each named function, closure, or macro, and a count indicates an <code>eval</code> in the immediately (lexically) enclosing named function, closure, or macro. Thus, the count gives an indication of the amount of time spent in a function, not counting nested function calls. The list of all functions executed is maintained on the global <code>*profile*</code> variable. These functions in turn have <code>*profile*</code> properties, which maintain the counts. The profile system merely increments counters and puts symbols on the <code>*profile*</code> list. It is up to the user to initialize data and gather results. Profiling is turned on or off with the <code>profile</code> function. Unfortunately, methods cannot be profiled with this facility.</p> |
| 534 |
<a name = "239"><h3>Symbols</h3></a><a name="index1499"></a><ul> |
| 535 |
<li> |
| 536 |
<code>self</code><a name="index1500"></a> - the current object (within a method context)</li> |
| 537 |
<li><code>*obarray*<a name="index1501"></a></code> - the object hash table</li> |
| 538 |
<li><code>*standard-input*<a name="index1502"></a></code> - the standard input stream</li> |
| 539 |
<li><code>*standard-output*<a name="index1503"></a></code> - the standard output stream</li> |
| 540 |
<li><code>*error-output*<a name="index1504"></a></code> - the error output stream</li> |
| 541 |
<li><code>*trace-output*<a name="index1505"></a></code> - the trace output stream</li> |
| 542 |
<li><code>*debug-io*<a name="index1506"></a></code> - the debug i/o stream</li> |
| 543 |
<li><code>*breakenable*<a name="index1507"></a></code> - flag controlling entering break loop on errors</li> |
| 544 |
<li><code>*tracelist*<a name="index1508"></a></code> - list of names of functions to trace</li> |
| 545 |
<li><code>*tracenable*<a name="index1509"></a></code> - enable trace back printout on errors</li> |
| 546 |
<li><code>*tracelimit*<a name="index1510"></a></code> - number of levels of trace back information</li> |
| 547 |
<li><code>*evalhook*<a name="index1511"></a></code> - user substitute for the evaluator function</li> |
| 548 |
<li><code>*applyhook*<a name="index1512"></a></code> - (not yet implemented)</li> |
| 549 |
<li><code>*readtable*<a name="index1513"></a></code> - the current readtable</li> |
| 550 |
<li><code>*unbound*<a name="index1514"></a></code> - indicator for unbound symbols</li> |
| 551 |
<li><code>*gc-flag*<a name="index1515"></a></code> - controls the printing of gc messages</li> |
| 552 |
<li><code>*gc-hook*<a name="index1516"></a></code> - function to call after garbage collection</li> |
| 553 |
<li><code>*integer-format*<a name="index1517"></a></code> - format for printing integers (“%d” or “%ld”)</li> |
| 554 |
<li><code>*float-format*<a name="index1518"></a></code> - format for printing floats (“%g”)</li> |
| 555 |
<li><code>*print-case*<a name="index1519"></a></code> - symbol output case (:upcase or :downcase) |
| 556 |
</li></ul> |
| 557 |
<p> There are several symbols maintained by the read/eval/print |
| 558 |
loop. The symbols <code>+</code>, <code>++</code>, and <code>+++</code> are bound to the most |
| 559 |
recent three input expressions. The symbols <code>*</code>, <code>**</code> and <code>***</code> |
| 560 |
are bound to the most recent three results. The symbol <code>-</code> is |
| 561 |
bound to the expression currently being evaluated. It becomes |
| 562 |
the value of <code>+</code> at the end of the evaluation. |
| 563 |
<a name = "240"><h3>Evaluation Functions</h3></a><a name="index1520"></a></p> |
| 564 |
<div style="padding-left: 0em;"> |
| 565 |
<code>eval<a name="index1521"></a>(<i>expr</i>)</code> [SAL]<br> |
| 566 |
<code>(eval <tt><i>expr</i></tt>)</code> [LISP] – evaluate an xlisp expression<br> |
| 567 |
|
| 568 |
|
| 569 |
</div><div style="padding-left: 2em;"> |
| 570 |
<i>expr</i> – the expression to be evaluated</div> |
| 571 |
<div style="padding-left: 2em;"> returns – the result of evaluating the expression<br> |
| 572 |
|
| 573 |
</div> |
| 574 |
<br> |
| 575 |
<code>apply<a name="index1522"></a>(<i>fun</i>, <i>args</i>)</code> [SAL]<br> |
| 576 |
<code>(apply <tt><i>fun</i></tt> <tt><i>args</i></tt>)</code> [LISP] – apply a function to a list of arguments<br> |
| 577 |
|
| 578 |
|
| 579 |
</div><div style="padding-left: 2em;"> |
| 580 |
<i>fun</i> – the function to apply (or function symbol)</div> |
| 581 |
<div style="padding-left: 2em;"> <i>args</i> – the argument list</div> |
| 582 |
<div style="padding-left: 2em;"> returns – the result of applying the function to the arguments<br> |
| 583 |
|
| 584 |
</div> |
| 585 |
<br> |
| 586 |
<code>funcall<a name="index1523"></a>(<i>fun</i>, <i>arg</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 587 |
<code>(funcall <tt><i>fun</i></tt> <tt><i>arg</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – call a function with arguments<br> |
| 588 |
|
| 589 |
|
| 590 |
</div><div style="padding-left: 2em;"> |
| 591 |
<i>fun</i> – the function to call (or function symbol)</div> |
| 592 |
<div style="padding-left: 2em;"> <i>arg</i> – arguments to pass to the function</div> |
| 593 |
<div style="padding-left: 2em;"> returns – the result of calling the function with the arguments<br> |
| 594 |
|
| 595 |
</div> |
| 596 |
<br> |
| 597 |
<code>quote<a name="index1524"></a>(<i>expr</i>)</code> [SAL]<br> |
| 598 |
<code>(quote <tt><i>expr</i></tt>)</code> [LISP] – return an expression unevaluated<br> |
| 599 |
|
| 600 |
|
| 601 |
</div><div style="padding-left: 2em;"> |
| 602 |
<i>expr</i> – the expression to be quoted (quoted)</div> |
| 603 |
<div style="padding-left: 2em;"> returns – <i>expr</i> unevaluated<br> |
| 604 |
|
| 605 |
</div> |
| 606 |
<br> |
| 607 |
<code>(function <tt><i>expr</i></tt>)</code> [LISP] – get the<br> |
| 608 |
|
| 609 |
functional interpretation. Note that in SAL, the function can be accessed as <code>#function</code>.<br> |
| 610 |
|
| 611 |
|
| 612 |
</div><div style="padding-left: 2em;"> |
| 613 |
<i>expr</i> – the symbol or lambda expression (quoted)</div> |
| 614 |
<div style="padding-left: 2em;"> returns – the functional interpretation<br> |
| 615 |
|
| 616 |
</div> |
| 617 |
<br> |
| 618 |
<code>backquote<a name="index1525"></a>(<i>expr</i>)</code> [SAL]<br> |
| 619 |
<code>(backquote <tt><i>expr</i></tt>)</code> [LISP] – fill in a template<br> |
| 620 |
|
| 621 |
|
| 622 |
</div><div style="padding-left: 2em;"> |
| 623 |
<i>expr</i> – the template</div> |
| 624 |
<div style="padding-left: 2em;"> returns – a copy of the template with comma and comma-at</div> |
| 625 |
<div style="padding-left: 2em;"> expressions expanded<br> |
| 626 |
|
| 627 |
</div> |
| 628 |
<br> |
| 629 |
<code>lambda<a name="index1526"></a>(<i>args</i>, <i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 630 |
<code>(lambda <tt><i>args</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – make a function closure<br> |
| 631 |
|
| 632 |
|
| 633 |
</div><div style="padding-left: 2em;"> |
| 634 |
<i>args</i> – formal argument list (lambda list) (quoted)</div> |
| 635 |
<div style="padding-left: 2em;"> <i>expr</i> – expressions of the function body</div> |
| 636 |
<div style="padding-left: 2em;"> returns – the function closure<br> |
| 637 |
|
| 638 |
</div> |
| 639 |
<br> |
| 640 |
<code>get-lambda-expression<a name="index1527"></a>(<i>closure</i>)</code> [SAL]<br> |
| 641 |
<code>(get-lambda-expression <tt><i>closure</i></tt>)</code> [LISP] – get the lambda expression<br> |
| 642 |
|
| 643 |
|
| 644 |
</div><div style="padding-left: 2em;"> |
| 645 |
<i>closure</i> – the closure</div> |
| 646 |
<div style="padding-left: 2em;"> returns – the original lambda expression<br> |
| 647 |
|
| 648 |
</div> |
| 649 |
<br> |
| 650 |
<code>macroexpand<a name="index1528"></a>(<i>form</i>)</code> [SAL]<br> |
| 651 |
<code>(macroexpand <tt><i>form</i></tt>)</code> [LISP] – recursively expand macro calls<br> |
| 652 |
|
| 653 |
|
| 654 |
</div><div style="padding-left: 2em;"> |
| 655 |
<i>form</i> – the form to expand</div> |
| 656 |
<div style="padding-left: 2em;"> returns – the macro expansion<br> |
| 657 |
|
| 658 |
</div> |
| 659 |
<br> |
| 660 |
<code>macroexpand-1<a name="index1529"></a>(<i>form</i>)</code> [SAL]<br> |
| 661 |
<code>(macroexpand-1 <tt><i>form</i></tt>)</code> [LISP] – expand a macro call<br> |
| 662 |
|
| 663 |
|
| 664 |
</div><div style="padding-left: 2em;"> |
| 665 |
<i>form</i> – the macro call form</div> |
| 666 |
<div style="padding-left: 2em;"> returns – the macro expansion<br> |
| 667 |
|
| 668 |
</div> |
| 669 |
|
| 670 |
</div> |
| 671 |
<a name = "241"><h3>Symbol Functions</h3></a><a name="index1530"></a><div style="padding-left: 0em;"> |
| 672 |
<code>(set<a name="index1531"></a> <tt><i>sym</i></tt> <tt><i>expr</i></tt>)</code> [LISP] – set the value of a symbol. Note that in SAL, the function can be accessed as <code>#set</code>.<br> |
| 673 |
|
| 674 |
|
| 675 |
</div><div style="padding-left: 2em;"> |
| 676 |
<i>sym</i> – the symbol being set</div> |
| 677 |
<div style="padding-left: 2em;"> <i>expr</i> – the new value</div> |
| 678 |
<div style="padding-left: 2em;"> returns – the new value<br> |
| 679 |
|
| 680 |
</div> |
| 681 |
<br> |
| 682 |
<code>setq<a name="index1532"></a>([<i>sym</i>, <i>expr</i>]<span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 683 |
<code>(setq [<tt><i>sym</i></tt> <tt><i>expr</i></tt>]<span style="font-style:normal">...</span>)</code> [LISP] – set the value of a symbol. Note that in SAL, the <code>set</code> command is normally used.<br> |
| 684 |
|
| 685 |
|
| 686 |
</div><div style="padding-left: 2em;"> |
| 687 |
<i>sym</i> – the symbol being set (quoted)</div> |
| 688 |
<div style="padding-left: 2em;"> <i>expr</i> – the new value</div> |
| 689 |
<div style="padding-left: 2em;"> returns – the new value<br> |
| 690 |
|
| 691 |
</div> |
| 692 |
<br> |
| 693 |
<code>psetq<a name="index1533"></a>([<i>sym</i>, <i>expr</i>]<span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 694 |
<code>(psetq [<tt><i>sym</i></tt> <tt><i>expr</i></tt>]<span style="font-style:normal">...</span>)</code> [LISP] – parallel version of setq<br> |
| 695 |
|
| 696 |
|
| 697 |
</div><div style="padding-left: 2em;"> |
| 698 |
<i>sym</i> – the symbol being set (quoted)</div> |
| 699 |
<div style="padding-left: 2em;"> <i>expr</i> – the new value</div> |
| 700 |
<div style="padding-left: 2em;"> returns – the new value<br> |
| 701 |
|
| 702 |
</div> |
| 703 |
<br> |
| 704 |
<code>setf<a name="index1534"></a>([<i>place</i>, <i>expr</i>]<span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 705 |
<code>(setf [<tt><i>place</i></tt> <tt><i>expr</i></tt>]<span style="font-style:normal">...</span>)</code> [LISP] – set the value of a field<br> |
| 706 |
|
| 707 |
|
| 708 |
</div><div style="padding-left: 2em;"> |
| 709 |
<i>place</i> – the field specifier (quoted):<br> |
| 710 |
|
| 711 |
</div><div style="padding-left: 4em;"> |
| 712 |
<i>sym</i> – set value of a symbol</div> |
| 713 |
<div style="padding-left: 4em;"> (car <i>expr</i>) – set car of a cons node</div> |
| 714 |
<div style="padding-left: 4em;"> (cdr <i>expr</i>) – set cdr of a cons node</div> |
| 715 |
<div style="padding-left: 4em;"> (nth <i>n</i> <i>expr</i>) – set nth car of a list</div> |
| 716 |
<div style="padding-left: 4em;"> (aref <i>expr</i> <i>n</i>) – set nth element of an array</div> |
| 717 |
<div style="padding-left: 4em;"> (get <i>sym</i> <i>prop</i>) – set value of a property</div> |
| 718 |
<div style="padding-left: 4em;"> (symbol-value <i>sym</i>) – set value of a symbol</div> |
| 719 |
<div style="padding-left: 4em;"> (symbol-function <i>sym</i>) – set functional value of a symbol</div> |
| 720 |
<div style="padding-left: 4em;"> (symbol-plist <i>sym</i>) – set property list of a symbol<br> |
| 721 |
|
| 722 |
</div></div> |
| 723 |
<div style="padding-left: 2em;"> <i>expr</i> – the new value</div> |
| 724 |
<div style="padding-left: 2em;"> returns – the new value<br> |
| 725 |
|
| 726 |
</div> |
| 727 |
<br> |
| 728 |
|
| 729 |
<code>(defun<a name="index1535"></a> <tt><i>sym</i></tt> <tt><i>fargs</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – define a function<br> |
| 730 |
<code>(defmacro<a name="index1536"></a> <tt><i>sym</i></tt> <tt><i>fargs</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – define a macro<br> |
| 731 |
|
| 732 |
|
| 733 |
</div><div style="padding-left: 2em;"> |
| 734 |
<i>sym</i> – symbol being defined (quoted)</div> |
| 735 |
<div style="padding-left: 2em;"> <i>fargs</i> – formal argument list (lambda list) (quoted)</div> |
| 736 |
<div style="padding-left: 2em;"> <i>expr</i> – expressions constituting the body of the</div> |
| 737 |
<div style="padding-left: 2em;"> function (quoted)<br> |
| 738 |
|
| 739 |
returns – the function symbol<br> |
| 740 |
|
| 741 |
</div> |
| 742 |
<br> |
| 743 |
<code>gensym<a name="index1537"></a>([<i>tag</i>])</code> [SAL]<br> |
| 744 |
<code>(gensym [<tt><i>tag</i></tt>])</code> [LISP] – generate a symbol<br> |
| 745 |
|
| 746 |
|
| 747 |
</div><div style="padding-left: 2em;"> |
| 748 |
<i>tag</i> – string or number</div> |
| 749 |
<div style="padding-left: 2em;"> returns – the new symbol<br> |
| 750 |
|
| 751 |
</div> |
| 752 |
<br> |
| 753 |
<code>intern<a name="index1538"></a>(<i>pname</i>)</code> [SAL]<br> |
| 754 |
<code>(intern <tt><i>pname</i></tt>)</code> [LISP] – make an interned symbol<br> |
| 755 |
|
| 756 |
|
| 757 |
</div><div style="padding-left: 2em;"> |
| 758 |
<i>pname</i> – the symbol's print name string</div> |
| 759 |
<div style="padding-left: 2em;"> returns – the new symbol<br> |
| 760 |
|
| 761 |
</div> |
| 762 |
<br> |
| 763 |
<code>make-symbol<a name="index1539"></a>(<i>pname</i>)</code> [SAL]<br> |
| 764 |
<code>(make-symbol <tt><i>pname</i></tt>)</code> [LISP] – make an uninterned symbol<br> |
| 765 |
|
| 766 |
|
| 767 |
</div><div style="padding-left: 2em;"> |
| 768 |
<i>pname</i> – the symbol's print name string</div> |
| 769 |
<div style="padding-left: 2em;"> returns – the new symbol<br> |
| 770 |
|
| 771 |
</div> |
| 772 |
<br> |
| 773 |
<code>symbol-name<a name="index1540"></a>(<i>sym</i>)</code> [SAL]<br> |
| 774 |
<code>(symbol-name <tt><i>sym</i></tt>)</code> [LISP] – get the print name of a symbol<br> |
| 775 |
|
| 776 |
|
| 777 |
</div><div style="padding-left: 2em;"> |
| 778 |
<i>sym</i> – the symbol</div> |
| 779 |
<div style="padding-left: 2em;"> returns – the symbol's print name<br> |
| 780 |
|
| 781 |
</div> |
| 782 |
<br> |
| 783 |
<code>symbol-value<a name="index1541"></a>(<i>sym</i>)</code> [SAL]<br> |
| 784 |
<code>(symbol-value <tt><i>sym</i></tt>)</code> [LISP] – get the value of a symbol<br> |
| 785 |
|
| 786 |
|
| 787 |
</div><div style="padding-left: 2em;"> |
| 788 |
<i>sym</i> – the symbol</div> |
| 789 |
<div style="padding-left: 2em;"> returns – the symbol's value<br> |
| 790 |
|
| 791 |
</div> |
| 792 |
<br> |
| 793 |
<code>symbol-function<a name="index1542"></a>(<i>sym</i>)</code> [SAL]<br> |
| 794 |
<code>(symbol-function <tt><i>sym</i></tt>)</code> [LISP] – get the functional value of a symbol<br> |
| 795 |
|
| 796 |
|
| 797 |
</div><div style="padding-left: 2em;"> |
| 798 |
<i>sym</i> – the symbol</div> |
| 799 |
<div style="padding-left: 2em;"> returns – the symbol's functional value<br> |
| 800 |
|
| 801 |
</div> |
| 802 |
<br> |
| 803 |
<code>symbol-plist<a name="index1543"></a>(<i>sym</i>)</code> [SAL]<br> |
| 804 |
<code>(symbol-plist <tt><i>sym</i></tt>)</code> [LISP] – get the property list of a symbol<br> |
| 805 |
|
| 806 |
|
| 807 |
</div><div style="padding-left: 2em;"> |
| 808 |
<i>sym</i> – the symbol</div> |
| 809 |
<div style="padding-left: 2em;"> returns – the symbol's property list<br> |
| 810 |
|
| 811 |
</div> |
| 812 |
<br> |
| 813 |
<code>hash<a name="index1544"></a>(<i>sym</i>, <i>n</i>)</code> [SAL]<br> |
| 814 |
<code>(hash <tt><i>sym</i></tt> <tt><i>n</i></tt>)</code> [LISP] – compute the hash index for a symbol<br> |
| 815 |
|
| 816 |
|
| 817 |
</div><div style="padding-left: 2em;"> |
| 818 |
<i>sym</i> – the symbol or string</div> |
| 819 |
<div style="padding-left: 2em;"> <i>n</i> – the table size (integer)</div> |
| 820 |
<div style="padding-left: 2em;"> returns – the hash index (integer)<br> |
| 821 |
|
| 822 |
</div> |
| 823 |
|
| 824 |
</div> |
| 825 |
<a name = "242"><h3>Property List Functions</h3></a><a name="index1545"></a><div style="padding-left: 0em;"> |
| 826 |
<code>get<a name="index1546"></a>(<i>sym</i>, <i>prop</i>)</code> [SAL]<br> |
| 827 |
<code>(get <tt><i>sym</i></tt> <tt><i>prop</i></tt>)</code> [LISP] – get the value of a property<br> |
| 828 |
|
| 829 |
|
| 830 |
</div><div style="padding-left: 2em;"> |
| 831 |
<i>sym</i> – the symbol</div> |
| 832 |
<div style="padding-left: 2em;"> <i>prop</i> – the property symbol</div> |
| 833 |
<div style="padding-left: 2em;"> returns – the property value or <code>nil</code><br> |
| 834 |
|
| 835 |
</div> |
| 836 |
<br> |
| 837 |
<code>putprop<a name="index1547"></a>(<i>sym</i>, <i>val</i>, <i>prop</i>)</code> [SAL]<br> |
| 838 |
<code>(putprop <tt><i>sym</i></tt> <tt><i>val</i></tt> <tt><i>prop</i></tt>)</code> [LISP] – put a property onto a property list<br> |
| 839 |
|
| 840 |
|
| 841 |
</div><div style="padding-left: 2em;"> |
| 842 |
<i>sym</i> – the symbol</div> |
| 843 |
<div style="padding-left: 2em;"> <i>val</i> – the property value</div> |
| 844 |
<div style="padding-left: 2em;"> <i>prop</i> – the property symbol</div> |
| 845 |
<div style="padding-left: 2em;"> returns – the property value<br> |
| 846 |
|
| 847 |
</div> |
| 848 |
<br> |
| 849 |
<code>remprop<a name="index1548"></a>(<i>sym</i>, <i>prop</i>)</code> [SAL]<br> |
| 850 |
<code>(remprop <tt><i>sym</i></tt> <tt><i>prop</i></tt>)</code> [LISP] – remove a property<br> |
| 851 |
|
| 852 |
|
| 853 |
</div><div style="padding-left: 2em;"> |
| 854 |
<i>sym</i> – the symbol</div> |
| 855 |
<div style="padding-left: 2em;"> <i>prop</i> – the property symbol</div> |
| 856 |
<div style="padding-left: 2em;"> returns – <code>nil</code><br> |
| 857 |
|
| 858 |
</div> |
| 859 |
|
| 860 |
</div> |
| 861 |
<a name = "243"><h3>Array Functions</h3></a><a name="index1549"></a><div style="padding-left: 0em;"> |
| 862 |
<code>aref<a name="index1550"></a>(<i>array</i>, <i>n</i>)</code> [SAL]<br> |
| 863 |
<code>(aref <tt><i>array</i></tt> <tt><i>n</i></tt>)</code> [LISP] – get the nth element of an array<br> |
| 864 |
|
| 865 |
|
| 866 |
</div><div style="padding-left: 2em;"> |
| 867 |
<i>array</i> – the array</div> |
| 868 |
<div style="padding-left: 2em;"> <i>n</i> – the array index (integer)</div> |
| 869 |
<div style="padding-left: 2em;"> returns – the value of the array element<br> |
| 870 |
|
| 871 |
</div> |
| 872 |
<br> |
| 873 |
<code>make-array<a name="index1551"></a>(<i>size</i>)</code> [SAL]<br> |
| 874 |
<code>(make-array <tt><i>size</i></tt>)</code> [LISP] – make a new array<br> |
| 875 |
|
| 876 |
|
| 877 |
</div><div style="padding-left: 2em;"> |
| 878 |
<i>size</i> – the size of the new array (integer)</div> |
| 879 |
<div style="padding-left: 2em;"> returns – the new array<br> |
| 880 |
|
| 881 |
</div> |
| 882 |
<br> |
| 883 |
<code>vector<a name="index1552"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 884 |
<code>(vector <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – make an initialized vector<br> |
| 885 |
|
| 886 |
|
| 887 |
</div><div style="padding-left: 2em;"> |
| 888 |
<i>expr</i> – the vector elements</div> |
| 889 |
<div style="padding-left: 2em;"> returns – the new vector<br> |
| 890 |
|
| 891 |
</div> |
| 892 |
|
| 893 |
</div> |
| 894 |
<a name = "244"><h3>List Functions</h3></a><a name="index1553"></a><div style="padding-left: 0em;"> |
| 895 |
<code>car<a name="index1554"></a>(<i>expr</i>)</code> [SAL]<br> |
| 896 |
<code>(car <tt><i>expr</i></tt>)</code> [LISP] – return the car of a list node<br> |
| 897 |
|
| 898 |
|
| 899 |
</div><div style="padding-left: 2em;"> |
| 900 |
<i>expr</i> – the list node</div> |
| 901 |
<div style="padding-left: 2em;"> returns – the car of the list node<br> |
| 902 |
|
| 903 |
</div> |
| 904 |
<br> |
| 905 |
<code>cdr<a name="index1555"></a>(<i>expr</i>)</code> [SAL]<br> |
| 906 |
<code>(cdr <tt><i>expr</i></tt>)</code> [LISP] – return the cdr of a list node<br> |
| 907 |
|
| 908 |
|
| 909 |
</div><div style="padding-left: 2em;"> |
| 910 |
<i>expr</i> – the list node</div> |
| 911 |
<div style="padding-left: 2em;"> returns – the cdr of the list node<br> |
| 912 |
|
| 913 |
</div> |
| 914 |
<br> |
| 915 |
<code>c<i>xx</i>r(<i>expr</i>)</code> [SAL]<br> |
| 916 |
<code>(c<i>xx</i>r<a name="index1556"></a> <tt><i>expr</i></tt>)</code> [LISP] – all c<i>xx</i>r combinations<br> |
| 917 |
|
| 918 |
|
| 919 |
</div><div style="padding-left: 2em;"> |
| 920 |
</div> |
| 921 |
<br> |
| 922 |
<code>c<i>xxx</i>r(<i>expr</i>)</code> [SAL]<br> |
| 923 |
<code>(c<i>xxx</i>r<a name="index1557"></a> <tt><i>expr</i></tt>)</code> [LISP] – all c<i>xxx</i>r combinations<br> |
| 924 |
|
| 925 |
|
| 926 |
</div><div style="padding-left: 2em;"> |
| 927 |
</div> |
| 928 |
<br> |
| 929 |
<code>c<i>xxxx</i>r(<i>expr</i>)</code> [SAL]<br> |
| 930 |
<code>(c<i>xxxx</i>r<a name="index1558"></a> <tt><i>expr</i></tt>)</code> [LISP] – all c<i>xxxx</i>r combinations<br> |
| 931 |
|
| 932 |
|
| 933 |
</div><div style="padding-left: 2em;"> |
| 934 |
</div> |
| 935 |
<br> |
| 936 |
<code>first<a name="index1559"></a>(<i>expr</i>)</code> [SAL]<br> |
| 937 |
<code>(first <tt><i>expr</i></tt>)</code> [LISP] – a synonym for car<br> |
| 938 |
|
| 939 |
|
| 940 |
</div><div style="padding-left: 2em;"> |
| 941 |
</div> |
| 942 |
<br> |
| 943 |
<code>second<a name="index1560"></a>(<i>expr</i>)</code> [SAL]<br> |
| 944 |
<code>(second <tt><i>expr</i></tt>)</code> [LISP] – a synonym for cadr<br> |
| 945 |
|
| 946 |
|
| 947 |
</div><div style="padding-left: 2em;"> |
| 948 |
</div> |
| 949 |
<br> |
| 950 |
<code>third<a name="index1561"></a>(<i>expr</i>)</code> [SAL]<br> |
| 951 |
<code>(third <tt><i>expr</i></tt>)</code> [LISP] – a synonym for caddr<br> |
| 952 |
|
| 953 |
|
| 954 |
</div><div style="padding-left: 2em;"> |
| 955 |
</div> |
| 956 |
<br> |
| 957 |
<code>fourth<a name="index1562"></a>(<i>expr</i>)</code> [SAL]<br> |
| 958 |
<code>(fourth <tt><i>expr</i></tt>)</code> [LISP] – a synonym for cadddr<br> |
| 959 |
|
| 960 |
|
| 961 |
</div><div style="padding-left: 2em;"> |
| 962 |
</div> |
| 963 |
<br> |
| 964 |
<code>rest<a name="index1563"></a>(<i>expr</i>)</code> [SAL]<br> |
| 965 |
<code>(rest <tt><i>expr</i></tt>)</code> [LISP] – a synonym for cdr<br> |
| 966 |
|
| 967 |
|
| 968 |
</div><div style="padding-left: 2em;"> |
| 969 |
</div> |
| 970 |
<br> |
| 971 |
<code>cons<a name="index1564"></a>(<i>expr1</i>, <i>expr2</i>)</code> [SAL]<br> |
| 972 |
<code>(cons <tt><i>expr1</i></tt> <tt><i>expr2</i></tt>)</code> [LISP] – construct a new list node<br> |
| 973 |
|
| 974 |
|
| 975 |
</div><div style="padding-left: 2em;"> |
| 976 |
<i>expr1</i> – the car of the new list node</div> |
| 977 |
<div style="padding-left: 2em;"> <i>expr2</i> – the cdr of the new list node</div> |
| 978 |
<div style="padding-left: 2em;"> returns – nil<br> |
| 979 |
|
| 980 |
</div> |
| 981 |
<br> |
| 982 |
<code>list<a name="index1565"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 983 |
<code>(list <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – create a list of values<br> |
| 984 |
|
| 985 |
|
| 986 |
</div><div style="padding-left: 2em;"> |
| 987 |
<i>expr</i> – expressions to be combined into a list</div> |
| 988 |
<div style="padding-left: 2em;"> returns – the new list<br> |
| 989 |
|
| 990 |
</div> |
| 991 |
<br> |
| 992 |
<code>append<a name="index1566"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 993 |
<code>(append <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – append lists<br> |
| 994 |
|
| 995 |
|
| 996 |
</div><div style="padding-left: 2em;"> |
| 997 |
<i>expr</i> – lists whose elements are to be appended</div> |
| 998 |
<div style="padding-left: 2em;"> returns – the new list<br> |
| 999 |
|
| 1000 |
</div> |
| 1001 |
<br> |
| 1002 |
<code>reverse<a name="index1567"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1003 |
<code>(reverse <tt><i>expr</i></tt>)</code> [LISP] – reverse a list<br> |
| 1004 |
|
| 1005 |
|
| 1006 |
</div><div style="padding-left: 2em;"> |
| 1007 |
<i>expr</i> – the list to reverse</div> |
| 1008 |
<div style="padding-left: 2em;"> returns – a new list in the reverse order<br> |
| 1009 |
|
| 1010 |
</div> |
| 1011 |
<br> |
| 1012 |
<code>last<a name="index1568"></a>(<i>list</i>)</code> [SAL]<br> |
| 1013 |
<code>(last <tt><i>list</i></tt>)</code> [LISP] – return the last list node of a list<br> |
| 1014 |
|
| 1015 |
|
| 1016 |
</div><div style="padding-left: 2em;"> |
| 1017 |
<i>list</i> – the list</div> |
| 1018 |
<div style="padding-left: 2em;"> returns – the last list node in the list<br> |
| 1019 |
|
| 1020 |
</div> |
| 1021 |
<br> |
| 1022 |
<code>member<a name="index1569"></a>(<i>expr</i>, <i>list</i>, test: <i>test</i>, test-not: <i>test-not</i>)</code> [SAL]<br> |
| 1023 |
<code>(member <tt><i>expr</i></tt> <tt><i>list</i></tt> <tt>&key </tt><tt>:test</tt> <tt>:test-not</tt>)</code> [LISP] – find an expression in a list<br> |
| 1024 |
|
| 1025 |
|
| 1026 |
</div><div style="padding-left: 2em;"> |
| 1027 |
<i>expr</i> – the expression to find</div> |
| 1028 |
<div style="padding-left: 2em;"> <i>list</i> – the list to search</div> |
| 1029 |
<div style="padding-left: 2em;"> :test – the test function (defaults to eql)</div> |
| 1030 |
<div style="padding-left: 2em;"> :test-not – the test function (sense inverted) </div> |
| 1031 |
<div style="padding-left: 2em;"> returns – the remainder of the list starting with the expression<br> |
| 1032 |
|
| 1033 |
</div> |
| 1034 |
<br> |
| 1035 |
<code>assoc<a name="index1570"></a>(<i>expr</i>, <i>alist</i>, test: <i>test</i>, test-not: <i>test-not</i>)</code> [SAL]<br> |
| 1036 |
<code>(assoc <tt><i>expr</i></tt> <tt><i>alist</i></tt> <tt>&key </tt><tt>:test</tt> <tt>:test-not</tt>)</code> [LISP] – find an expression in an a-list<br> |
| 1037 |
|
| 1038 |
|
| 1039 |
</div><div style="padding-left: 2em;"> |
| 1040 |
<i>expr</i> – the expression to find</div> |
| 1041 |
<div style="padding-left: 2em;"> <i>alist</i> – the association list</div> |
| 1042 |
<div style="padding-left: 2em;"> :test – the test function (defaults to eql)</div> |
| 1043 |
<div style="padding-left: 2em;"> :test-not – the test function (sense inverted) </div> |
| 1044 |
<div style="padding-left: 2em;"> returns – the alist entry or <code>nil</code><br> |
| 1045 |
|
| 1046 |
</div> |
| 1047 |
<br> |
| 1048 |
<code>remove<a name="index1571"></a>(<i>expr</i>, <i>list</i>, test: <i>test</i>, test-not: <i>test-not</i>)</code> [SAL]<br> |
| 1049 |
<code>(remove <tt><i>expr</i></tt> <tt><i>list</i></tt> <tt>&key </tt><tt>:test</tt> <tt>:test-not</tt>)</code> [LISP] – remove elements from a list<br> |
| 1050 |
|
| 1051 |
|
| 1052 |
</div><div style="padding-left: 2em;"> |
| 1053 |
<i>expr</i> – the element to remove</div> |
| 1054 |
<div style="padding-left: 2em;"> <i>list</i> – the list</div> |
| 1055 |
<div style="padding-left: 2em;"> :test – the test function (defaults to eql)</div> |
| 1056 |
<div style="padding-left: 2em;"> :test-not – the test function (sense inverted) </div> |
| 1057 |
<div style="padding-left: 2em;"> returns – copy of list with matching expressions removed<br> |
| 1058 |
|
| 1059 |
</div> |
| 1060 |
<br> |
| 1061 |
<code>remove-if<a name="index1572"></a>(<i>test</i>, <i>list</i>)</code> [SAL]<br> |
| 1062 |
<code>(remove-if <tt><i>test</i></tt> <tt><i>list</i></tt>)</code> [LISP] – remove elements that pass test<br> |
| 1063 |
|
| 1064 |
|
| 1065 |
</div><div style="padding-left: 2em;"> |
| 1066 |
<i>test</i> – the test predicate</div> |
| 1067 |
<div style="padding-left: 2em;"> <i>list</i> – the list</div> |
| 1068 |
<div style="padding-left: 2em;"> returns – copy of list with matching elements removed<br> |
| 1069 |
|
| 1070 |
</div> |
| 1071 |
<br> |
| 1072 |
<code>remove-if-not<a name="index1573"></a>(<i>test</i>, <i>list</i>)</code> [SAL]<br> |
| 1073 |
<code>(remove-if-not <tt><i>test</i></tt> <tt><i>list</i></tt>)</code> [LISP] – remove elements that fail test<br> |
| 1074 |
|
| 1075 |
|
| 1076 |
</div><div style="padding-left: 2em;"> |
| 1077 |
<i>test</i> – the test predicate</div> |
| 1078 |
<div style="padding-left: 2em;"> <i>list</i> – the list</div> |
| 1079 |
<div style="padding-left: 2em;"> returns – copy of list with non-matching elements removed<br> |
| 1080 |
|
| 1081 |
</div> |
| 1082 |
<br> |
| 1083 |
<code>length<a name="index1574"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1084 |
<code>(length <tt><i>expr</i></tt>)</code> [LISP] – find the length of a list, vector or string<br> |
| 1085 |
|
| 1086 |
|
| 1087 |
</div><div style="padding-left: 2em;"> |
| 1088 |
<i>expr</i> – the list, vector or string</div> |
| 1089 |
<div style="padding-left: 2em;"> returns – the length of the list, vector or string<br> |
| 1090 |
|
| 1091 |
</div> |
| 1092 |
<br> |
| 1093 |
<code>nth<a name="index1575"></a>(<i>n</i>, <i>list</i>)</code> [SAL]<br> |
| 1094 |
<code>(nth <tt><i>n</i></tt> <tt><i>list</i></tt>)</code> [LISP] – return the nth element of a list<br> |
| 1095 |
|
| 1096 |
|
| 1097 |
</div><div style="padding-left: 2em;"> |
| 1098 |
<i>n</i> – the number of the element to return (zero origin)</div> |
| 1099 |
<div style="padding-left: 2em;"> <i>list</i> – the list</div> |
| 1100 |
<div style="padding-left: 2em;"> returns – the nth element or <code>nil</code> if the list isn't that long<br> |
| 1101 |
|
| 1102 |
</div> |
| 1103 |
<br> |
| 1104 |
<code>nthcdr<a name="index1576"></a>(<i>n</i>, <i>list</i>)</code> [SAL]<br> |
| 1105 |
<code>(nthcdr <tt><i>n</i></tt> <tt><i>list</i></tt>)</code> [LISP] – return the nth cdr of a list<br> |
| 1106 |
|
| 1107 |
|
| 1108 |
</div><div style="padding-left: 2em;"> |
| 1109 |
<i>n</i> – the number of the element to return (zero origin)</div> |
| 1110 |
<div style="padding-left: 2em;"> <i>list</i> – the list</div> |
| 1111 |
<div style="padding-left: 2em;"> returns – the nth cdr or <code>nil</code> if the list isn't that long<br> |
| 1112 |
|
| 1113 |
</div> |
| 1114 |
<br> |
| 1115 |
<code>mapc<a name="index1577"></a>(<i>fcn</i>, <i>list1</i>, <i>list</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1116 |
<code>(mapc <tt><i>fcn</i></tt> <tt><i>list1</i></tt> <tt><i>list</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – apply function to successive cars<br> |
| 1117 |
|
| 1118 |
|
| 1119 |
</div><div style="padding-left: 2em;"> |
| 1120 |
<i>fcn</i> – the function or function name</div> |
| 1121 |
<div style="padding-left: 2em;"> <i>listn</i> – a list for each argument of the function</div> |
| 1122 |
<div style="padding-left: 2em;"> returns – the first list of arguments<br> |
| 1123 |
|
| 1124 |
</div> |
| 1125 |
<br> |
| 1126 |
<code>mapcar<a name="index1578"></a>(<i>fcn</i>, <i>list1</i>, <i>list</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1127 |
<code>(mapcar <tt><i>fcn</i></tt> <tt><i>list1</i></tt> <tt><i>list</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – apply function to successive cars<br> |
| 1128 |
|
| 1129 |
|
| 1130 |
</div><div style="padding-left: 2em;"> |
| 1131 |
<i>fcn</i> – the function or function name</div> |
| 1132 |
<div style="padding-left: 2em;"> <i>listn</i> – a list for each argument of the function</div> |
| 1133 |
<div style="padding-left: 2em;"> returns – a list of the values returned<br> |
| 1134 |
|
| 1135 |
</div> |
| 1136 |
<br> |
| 1137 |
<code>mapl<a name="index1579"></a>(<i>fcn</i>, <i>list1</i>, <i>list</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1138 |
<code>(mapl <tt><i>fcn</i></tt> <tt><i>list1</i></tt> <tt><i>list</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – apply function to successive cdrs<br> |
| 1139 |
|
| 1140 |
|
| 1141 |
</div><div style="padding-left: 2em;"> |
| 1142 |
<i>fcn</i> – the function or function name</div> |
| 1143 |
<div style="padding-left: 2em;"> <i>listn</i> – a list for each argument of the function</div> |
| 1144 |
<div style="padding-left: 2em;"> returns – the first list of arguments<br> |
| 1145 |
|
| 1146 |
</div> |
| 1147 |
<br> |
| 1148 |
<code>maplist<a name="index1580"></a>(<i>fcn</i>, <i>list1</i>, <i>list</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1149 |
<code>(maplist <tt><i>fcn</i></tt> <tt><i>list1</i></tt> <tt><i>list</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – apply function to successive cdrs<br> |
| 1150 |
|
| 1151 |
|
| 1152 |
</div><div style="padding-left: 2em;"> |
| 1153 |
<i>fcn</i> – the function or function name</div> |
| 1154 |
<div style="padding-left: 2em;"> <i>listn</i> – a list for each argument of the function</div> |
| 1155 |
<div style="padding-left: 2em;"> returns – a list of the values returned<br> |
| 1156 |
|
| 1157 |
</div> |
| 1158 |
<br> |
| 1159 |
<code>subst<a name="index1581"></a>(<i>to</i>, <i>from</i>, <i>expr</i>, test: <i>test</i>, test-not: <i>test-not</i>)</code> [SAL]<br> |
| 1160 |
<code>(subst <tt><i>to</i></tt> <tt><i>from</i></tt> <tt><i>expr</i></tt> <tt>&key </tt><tt>:test</tt> <tt>:test-not</tt>)</code> [LISP] – substitute expressions<br> |
| 1161 |
|
| 1162 |
|
| 1163 |
</div><div style="padding-left: 2em;"> |
| 1164 |
<i>to</i> – the new expression</div> |
| 1165 |
<div style="padding-left: 2em;"> <i>from</i> – the old expression</div> |
| 1166 |
<div style="padding-left: 2em;"> <i>expr</i> – the expression in which to do the substitutions</div> |
| 1167 |
<div style="padding-left: 2em;"> :test – the test function (defaults to eql)</div> |
| 1168 |
<div style="padding-left: 2em;"> :test-not – the test function (sense inverted) </div> |
| 1169 |
<div style="padding-left: 2em;"> returns – the expression with substitutions<br> |
| 1170 |
|
| 1171 |
</div> |
| 1172 |
<br> |
| 1173 |
<code>sublis<a name="index1582"></a>(<i>alist</i>, <i>expr</i>, test: <i>test</i>, test-not: <i>test-not</i>)</code> [SAL]<br> |
| 1174 |
<code>(sublis <tt><i>alist</i></tt> <tt><i>expr</i></tt> <tt>&key </tt><tt>:test</tt> <tt>:test-not</tt>)</code> [LISP] – substitute with an a-list<br> |
| 1175 |
|
| 1176 |
|
| 1177 |
</div><div style="padding-left: 2em;"> |
| 1178 |
<i>alist</i> – the association list</div> |
| 1179 |
<div style="padding-left: 2em;"> <i>expr</i> – the expression in which to do the substitutions</div> |
| 1180 |
<div style="padding-left: 2em;"> :test – the test function (defaults to eql)</div> |
| 1181 |
<div style="padding-left: 2em;"> :test-not – the test function (sense inverted) </div> |
| 1182 |
<div style="padding-left: 2em;"> returns – the expression with substitutions<br> |
| 1183 |
|
| 1184 |
</div> |
| 1185 |
|
| 1186 |
</div> |
| 1187 |
<a name = "245"><h3>Destructive List Functions</h3></a><a name="index1583"></a><div style="padding-left: 0em;"> |
| 1188 |
<code>rplaca<a name="index1584"></a>(<i>list</i>, <i>expr</i>)</code> [SAL]<br> |
| 1189 |
<code>(rplaca <tt><i>list</i></tt> <tt><i>expr</i></tt>)</code> [LISP] – replace the car of a list node<br> |
| 1190 |
|
| 1191 |
|
| 1192 |
</div><div style="padding-left: 2em;"> |
| 1193 |
<i>list</i> – the list node</div> |
| 1194 |
<div style="padding-left: 2em;"> <i>expr</i> – the new value for the car of the list node</div> |
| 1195 |
<div style="padding-left: 2em;"> returns – the list node after updating the car<br> |
| 1196 |
|
| 1197 |
</div> |
| 1198 |
<br> |
| 1199 |
<code>rplacd<a name="index1585"></a>(<i>list</i>, <i>expr</i>)</code> [SAL]<br> |
| 1200 |
<code>(rplacd <tt><i>list</i></tt> <tt><i>expr</i></tt>)</code> [LISP] – replace the cdr of a list node<br> |
| 1201 |
|
| 1202 |
|
| 1203 |
</div><div style="padding-left: 2em;"> |
| 1204 |
<i>list</i> – the list node</div> |
| 1205 |
<div style="padding-left: 2em;"> <i>expr</i> – the new value for the cdr of the list node</div> |
| 1206 |
<div style="padding-left: 2em;"> returns – the list node after updating the cdr<br> |
| 1207 |
|
| 1208 |
</div> |
| 1209 |
<br> |
| 1210 |
<code>nconc<a name="index1586"></a>(<i>list</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1211 |
<code>(nconc <tt><i>list</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – destructively concatenate lists<br> |
| 1212 |
|
| 1213 |
|
| 1214 |
</div><div style="padding-left: 2em;"> |
| 1215 |
<i>list</i> – lists to concatenate</div> |
| 1216 |
<div style="padding-left: 2em;"> returns – the result of concatenating the lists<br> |
| 1217 |
|
| 1218 |
</div> |
| 1219 |
<br> |
| 1220 |
<code>delete<a name="index1587"></a>(<i>expr</i>, <i>list</i>, test: <i>test</i>, test-not: <i>test-not</i>)</code> [SAL]<br> |
| 1221 |
<code>(delete <tt><i>expr</i></tt> <tt><i>list</i></tt> <tt>&key </tt><tt>:test</tt> <tt>:test-not</tt>)</code> [LISP] – delete elements from a list<br> |
| 1222 |
|
| 1223 |
|
| 1224 |
</div><div style="padding-left: 2em;"> |
| 1225 |
<i>expr</i> – the element to delete</div> |
| 1226 |
<div style="padding-left: 2em;"> <i>list</i> – the list</div> |
| 1227 |
<div style="padding-left: 2em;"> :test – the test function (defaults to eql)</div> |
| 1228 |
<div style="padding-left: 2em;"> :test-not – the test function (sense inverted) </div> |
| 1229 |
<div style="padding-left: 2em;"> returns – the list with the matching expressions deleted<br> |
| 1230 |
|
| 1231 |
</div> |
| 1232 |
<br> |
| 1233 |
<code>delete-if<a name="index1588"></a>(<i>test</i>, <i>list</i>)</code> [SAL]<br> |
| 1234 |
<code>(delete-if <tt><i>test</i></tt> <tt><i>list</i></tt>)</code> [LISP] – delete elements that pass test<br> |
| 1235 |
|
| 1236 |
|
| 1237 |
</div><div style="padding-left: 2em;"> |
| 1238 |
<i>test</i> – the test predicate</div> |
| 1239 |
<div style="padding-left: 2em;"> <i>list</i> – the list</div> |
| 1240 |
<div style="padding-left: 2em;"> returns – the list with matching elements deleted<br> |
| 1241 |
|
| 1242 |
</div> |
| 1243 |
<br> |
| 1244 |
<code>delete-if-not<a name="index1589"></a>(<i>test</i>, <i>list</i>)</code> [SAL]<br> |
| 1245 |
<code>(delete-if-not) <tt><i>test</i></tt> <tt><i>list</i></tt>)</code> [LISP] – delete elements that fail test<br> |
| 1246 |
|
| 1247 |
|
| 1248 |
</div><div style="padding-left: 2em;"> |
| 1249 |
<i>test</i> – the test predicate</div> |
| 1250 |
<div style="padding-left: 2em;"> <i>list</i> – the list</div> |
| 1251 |
<div style="padding-left: 2em;"> returns – the list with non-matching elements deleted<br> |
| 1252 |
|
| 1253 |
</div> |
| 1254 |
<br> |
| 1255 |
<code>sort<a name="index1590"></a>(<i>list</i>, <i>test</i>)</code> [SAL]<br> |
| 1256 |
<code>(sort <tt><i>list</i></tt> <tt><i>test</i></tt>)</code> [LISP] – sort a list<br> |
| 1257 |
|
| 1258 |
|
| 1259 |
</div><div style="padding-left: 2em;"> |
| 1260 |
<i>list</i> – the list to sort</div> |
| 1261 |
<div style="padding-left: 2em;"> <i>test</i> – the comparison function</div> |
| 1262 |
<div style="padding-left: 2em;"> returns – the sorted list</div> |
| 1263 |
<div style="padding-left: 2em;"> Note: The comparison function should have two parameters and return true if the first parameter should come before the second parameter in the sorted result. For a list of numbers, built-in comparison functions can be used, e.g. <tt>(sort '(3 2 1) #'<)</tt> returns <tt>(1 2 3)</tt>. To sort a list of lists by the first element of each list, you can write a function to access the keys and compare them, e.g. <br> |
| 1264 |
|
| 1265 |
<tt>(sort '((3 c) (2 b) (1 a)) #'(lambda (x y) (< (car x) (car y))))</tt> returns<br> |
| 1266 |
|
| 1267 |
<tt>((1 A) (2 B) (3 C))</tt>. In SAL, you could write<br> |
| 1268 |
|
| 1269 |
<tt>function my-sort(a, b) return first(a) < first(b)</tt><br> |
| 1270 |
|
| 1271 |
<tt>print sort({{3 c} {2 b} {1 a}}, quote(my-sort))</tt>, which will print<br> |
| 1272 |
|
| 1273 |
<tt>{{1 A} {2 B} {3 C}}</tt>.</div> |
| 1274 |
<div style="padding-left: 2em;"></div> |
| 1275 |
<br> |
| 1276 |
|
| 1277 |
</div> |
| 1278 |
<a name = "246"><h3>Predicate Functions</h3></a><a name="index1591"></a><div style="padding-left: 0em;"> |
| 1279 |
<code>atom<a name="index1592"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1280 |
<code>(atom <tt><i>expr</i></tt>)</code> [LISP] – is this an atom?<br> |
| 1281 |
|
| 1282 |
|
| 1283 |
</div><div style="padding-left: 2em;"> |
| 1284 |
<i>expr</i> – the expression to check</div> |
| 1285 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is an atom, <code>nil</code> otherwise<br> |
| 1286 |
|
| 1287 |
</div> |
| 1288 |
<br> |
| 1289 |
<code>symbolp<a name="index1593"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1290 |
<code>(symbolp <tt><i>expr</i></tt>)</code> [LISP] – is this a symbol?<br> |
| 1291 |
|
| 1292 |
|
| 1293 |
</div><div style="padding-left: 2em;"> |
| 1294 |
<i>expr</i> – the expression to check</div> |
| 1295 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the expression is a symbol, <code>nil</code> otherwise<br> |
| 1296 |
|
| 1297 |
</div> |
| 1298 |
<br> |
| 1299 |
<code>numberp<a name="index1594"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1300 |
<code>(numberp <tt><i>expr</i></tt>)</code> [LISP] – is this a number?<br> |
| 1301 |
|
| 1302 |
|
| 1303 |
</div><div style="padding-left: 2em;"> |
| 1304 |
<i>expr</i> – the expression to check</div> |
| 1305 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the expression is a number, <code>nil</code> otherwise<br> |
| 1306 |
|
| 1307 |
</div> |
| 1308 |
<br> |
| 1309 |
<code>null<a name="index1595"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1310 |
<code>(null <tt><i>expr</i></tt>)</code> [LISP] – is this an empty list?<br> |
| 1311 |
|
| 1312 |
|
| 1313 |
</div><div style="padding-left: 2em;"> |
| 1314 |
<i>expr</i> – the list to check</div> |
| 1315 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the list is empty, <code>nil</code> otherwise<br> |
| 1316 |
|
| 1317 |
</div> |
| 1318 |
<br> |
| 1319 |
<code>not<a name="index1596"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1320 |
<code>(not <tt><i>expr</i></tt>)</code> [LISP] – is this false?<br> |
| 1321 |
|
| 1322 |
|
| 1323 |
</div><div style="padding-left: 2em;"> |
| 1324 |
<i>expr</i> – the expression to check</div> |
| 1325 |
<div style="padding-left: 2em;"> return – <code>t</code> if the value is <code>nil</code>, <code>nil</code> otherwise<br> |
| 1326 |
|
| 1327 |
</div> |
| 1328 |
<br> |
| 1329 |
<code>listp<a name="index1597"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1330 |
<code>(listp <tt><i>expr</i></tt>)</code> [LISP] – is this a list?<br> |
| 1331 |
|
| 1332 |
|
| 1333 |
</div><div style="padding-left: 2em;"> |
| 1334 |
<i>expr</i> – the expression to check</div> |
| 1335 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is a cons or <code>nil</code>, <code>nil</code> otherwise<br> |
| 1336 |
|
| 1337 |
</div> |
| 1338 |
<br> |
| 1339 |
<code>endp<a name="index1598"></a>(<i>list</i>)</code> [SAL]<br> |
| 1340 |
<code>(endp <tt><i>list</i></tt>)</code> [LISP] – is this the end of a list<br> |
| 1341 |
|
| 1342 |
|
| 1343 |
</div><div style="padding-left: 2em;"> |
| 1344 |
<i>list</i> – the list</div> |
| 1345 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is <code>nil</code>, <code>nil</code> otherwise<br> |
| 1346 |
|
| 1347 |
</div> |
| 1348 |
<br> |
| 1349 |
<code>consp<a name="index1599"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1350 |
<code>(consp <tt><i>expr</i></tt>)</code> [LISP] – is this a non-empty list?<br> |
| 1351 |
|
| 1352 |
|
| 1353 |
</div><div style="padding-left: 2em;"> |
| 1354 |
<i>expr</i> – the expression to check</div> |
| 1355 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is a cons, <code>nil</code> otherwise<br> |
| 1356 |
|
| 1357 |
</div> |
| 1358 |
<br> |
| 1359 |
<code>integerp<a name="index1600"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1360 |
<code>(integerp <tt><i>expr</i></tt>)</code> [LISP] – is this an integer?<br> |
| 1361 |
|
| 1362 |
|
| 1363 |
</div><div style="padding-left: 2em;"> |
| 1364 |
<i>expr</i> – the expression to check</div> |
| 1365 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is an integer, <code>nil</code> otherwise<br> |
| 1366 |
|
| 1367 |
</div> |
| 1368 |
<br> |
| 1369 |
<code>floatp<a name="index1601"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1370 |
<code>(floatp <tt><i>expr</i></tt>)</code> [LISP] – is this a float?<br> |
| 1371 |
|
| 1372 |
|
| 1373 |
</div><div style="padding-left: 2em;"> |
| 1374 |
<i>expr</i> – the expression to check</div> |
| 1375 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is a float, <code>nil</code> otherwise<br> |
| 1376 |
|
| 1377 |
</div> |
| 1378 |
<br> |
| 1379 |
<code>stringp<a name="index1602"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1380 |
<code>(stringp <tt><i>expr</i></tt>)</code> [LISP] – is this a string?<br> |
| 1381 |
|
| 1382 |
|
| 1383 |
</div><div style="padding-left: 2em;"> |
| 1384 |
<i>expr</i> – the expression to check</div> |
| 1385 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is a string, <code>nil</code> otherwise<br> |
| 1386 |
|
| 1387 |
</div> |
| 1388 |
<br> |
| 1389 |
<code>characterp<a name="index1603"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1390 |
<code>(characterp <tt><i>expr</i></tt>)</code> [LISP] – is this a character?<br> |
| 1391 |
|
| 1392 |
|
| 1393 |
</div><div style="padding-left: 2em;"> |
| 1394 |
<i>expr</i> – the expression to check</div> |
| 1395 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is a character, <code>nil</code> otherwise<br> |
| 1396 |
|
| 1397 |
</div> |
| 1398 |
<br> |
| 1399 |
<code>arrayp<a name="index1604"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1400 |
<code>(arrayp <tt><i>expr</i></tt>)</code> [LISP] – is this an array?<br> |
| 1401 |
|
| 1402 |
|
| 1403 |
</div><div style="padding-left: 2em;"> |
| 1404 |
<i>expr</i> – the expression to check</div> |
| 1405 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is an array, <code>nil</code> otherwise<br> |
| 1406 |
|
| 1407 |
</div> |
| 1408 |
<br> |
| 1409 |
<code>streamp<a name="index1605"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1410 |
<code>(streamp <tt><i>expr</i></tt>)</code> [LISP] – is this a stream?<br> |
| 1411 |
|
| 1412 |
|
| 1413 |
</div><div style="padding-left: 2em;"> |
| 1414 |
<i>expr</i> – the expression to check</div> |
| 1415 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is a stream, <code>nil</code> otherwise<br> |
| 1416 |
|
| 1417 |
</div> |
| 1418 |
<br> |
| 1419 |
<code>objectp<a name="index1606"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1420 |
<code>(objectp <tt><i>expr</i></tt>)</code> [LISP] – is this an object?<br> |
| 1421 |
|
| 1422 |
|
| 1423 |
</div><div style="padding-left: 2em;"> |
| 1424 |
<i>expr</i> – the expression to check</div> |
| 1425 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is an object, <code>nil</code> otherwise<br> |
| 1426 |
|
| 1427 |
</div> |
| 1428 |
<br> |
| 1429 |
<code>filep<a name="index1607"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1430 |
<code>(filep <tt><i>expr</i></tt>)</code> [LISP] – is this a file? <br> |
| 1431 |
|
| 1432 |
|
| 1433 |
</div><div style="padding-left: 2em;"> |
| 1434 |
<i>expr</i> – the expression to check</div> |
| 1435 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the value is an object, <code>nil</code> otherwise</div> |
| 1436 |
<div style="padding-left: 2em;"> This is not part of standard XLISP nor is it built-in. Nyquist defines it though.<br> |
| 1437 |
|
| 1438 |
</div> |
| 1439 |
<br> |
| 1440 |
<code>boundp<a name="index1608"></a>(<i>sym</i>)</code> [SAL]<br> |
| 1441 |
<code>(boundp <tt><i>sym</i></tt>)</code> [LISP] – is a value bound to this symbol?<br> |
| 1442 |
|
| 1443 |
|
| 1444 |
</div><div style="padding-left: 2em;"> |
| 1445 |
<i>sym</i> – the symbol</div> |
| 1446 |
<div style="padding-left: 2em;"> returns – <code>t</code> if a value is bound to the symbol, <code>nil</code> otherwise<br> |
| 1447 |
|
| 1448 |
</div> |
| 1449 |
<br> |
| 1450 |
<code>fboundp<a name="index1609"></a>(<i>sym</i>)</code> [SAL]<br> |
| 1451 |
<code>(fboundp <tt><i>sym</i></tt>)</code> [LISP] – is a functional value bound to this symbol?<br> |
| 1452 |
|
| 1453 |
|
| 1454 |
</div><div style="padding-left: 2em;"> |
| 1455 |
<i>sym</i> – the symbol</div> |
| 1456 |
<div style="padding-left: 2em;"> returns – <code>t</code> if a functional value is bound to the symbol,</div> |
| 1457 |
<div style="padding-left: 2em;"> <code>nil</code> otherwise<br> |
| 1458 |
|
| 1459 |
</div> |
| 1460 |
<br> |
| 1461 |
<code>minusp<a name="index1610"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1462 |
<code>(minusp <tt><i>expr</i></tt>)</code> [LISP] – is this number negative?<br> |
| 1463 |
|
| 1464 |
|
| 1465 |
</div><div style="padding-left: 2em;"> |
| 1466 |
<i>expr</i> – the number to test</div> |
| 1467 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the number is negative, <code>nil</code> otherwise<br> |
| 1468 |
|
| 1469 |
</div> |
| 1470 |
<br> |
| 1471 |
<code>zerop<a name="index1611"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1472 |
<code>(zerop <tt><i>expr</i></tt>)</code> [LISP] – is this number zero?<br> |
| 1473 |
|
| 1474 |
|
| 1475 |
</div><div style="padding-left: 2em;"> |
| 1476 |
<i>expr</i> – the number to test</div> |
| 1477 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the number is zero, <code>nil</code> otherwise<br> |
| 1478 |
|
| 1479 |
</div> |
| 1480 |
<br> |
| 1481 |
<code>plusp<a name="index1612"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1482 |
<code>(plusp <tt><i>expr</i></tt>)</code> [LISP] – is this number positive?<br> |
| 1483 |
|
| 1484 |
|
| 1485 |
</div><div style="padding-left: 2em;"> |
| 1486 |
<i>expr</i> – the number to test</div> |
| 1487 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the number is positive, <code>nil</code> otherwise<br> |
| 1488 |
|
| 1489 |
</div> |
| 1490 |
<br> |
| 1491 |
<code>evenp<a name="index1613"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1492 |
<code>(evenp <tt><i>expr</i></tt>)</code> [LISP] – is this integer even?<br> |
| 1493 |
|
| 1494 |
|
| 1495 |
</div><div style="padding-left: 2em;"> |
| 1496 |
<i>expr</i> – the integer to test</div> |
| 1497 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the integer is even, <code>nil</code> otherwise<br> |
| 1498 |
|
| 1499 |
</div> |
| 1500 |
<br> |
| 1501 |
<code>oddp<a name="index1614"></a>(<i>expr</i>)</code> [SAL]<br> |
| 1502 |
<code>(oddp <tt><i>expr</i></tt>)</code> [LISP] – is this integer odd?<br> |
| 1503 |
|
| 1504 |
|
| 1505 |
</div><div style="padding-left: 2em;"> |
| 1506 |
<i>expr</i> – the integer to test</div> |
| 1507 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the integer is odd, <code>nil</code> otherwise<br> |
| 1508 |
|
| 1509 |
</div> |
| 1510 |
<br> |
| 1511 |
<code>eq<a name="index1615"></a>(<i>expr1</i>, <i>expr2</i>)</code> [SAL]<br> |
| 1512 |
<code>(eq <tt><i>expr1</i></tt> <tt><i>expr2</i></tt>)</code> [LISP] – are the expressions identical (pointer equality)? Numbers and strings are generally not <code>eq</code>, e.g. <code>(eq 256 256)</code>, <code>(eq 1.0 1.0)</code>, and <code>(eq "a" "a")</code> are false.<br> |
| 1513 |
|
| 1514 |
|
| 1515 |
</div><div style="padding-left: 2em;"> |
| 1516 |
<i>expr1</i> – the first expression</div> |
| 1517 |
<div style="padding-left: 2em;"> <i>expr2</i> – the second expression</div> |
| 1518 |
<div style="padding-left: 2em;"> returns – <code>t</code> if they are equal, <code>nil</code> otherwise<br> |
| 1519 |
|
| 1520 |
</div> |
| 1521 |
<br> |
| 1522 |
<code>eql<a name="index1616"></a>(<i>expr1</i>, <i>expr2</i>)</code> [SAL]<br> |
| 1523 |
<code>(eql <tt><i>expr1</i></tt> <tt><i>expr2</i></tt>)</code> [LISP] – are the expressions of equal value? (<code>eql</code> tests for identical objects (pointer equality) except for numbers. Two numbers can be <code>eql</code> even if they are stored in different locations. However, a FIXNUM is never <code>eql</code> to a FLONUM, i.e. <code>(eql 1 1.0)</code> is false.)<br> |
| 1524 |
|
| 1525 |
|
| 1526 |
</div><div style="padding-left: 2em;"> |
| 1527 |
<i>expr1</i> – the first expression</div> |
| 1528 |
<div style="padding-left: 2em;"> <i>expr2</i> – the second expression</div> |
| 1529 |
<div style="padding-left: 2em;"> returns – <code>t</code> if they are equal, <code>nil</code> otherwise<br> |
| 1530 |
|
| 1531 |
</div> |
| 1532 |
<br> |
| 1533 |
<code>equal<a name="index1617"></a>(<i>expr1</i>, <i>expr2</i>)</code> [SAL]<br> |
| 1534 |
<code>(equal <tt><i>expr1</i></tt> <tt><i>expr2</i></tt>)</code> [LISP] – are the expressions equal? Arrays are not <code>equal</code> unless they are the same array (pointer equality), but numbers and strings are compared by value, and lists are tested recursively for <code>equal</code> content. A FIXNUM is never <code>equal</code> to a FLONUM.<br> |
| 1535 |
|
| 1536 |
|
| 1537 |
</div><div style="padding-left: 2em;"> |
| 1538 |
<i>expr1</i> – the first expression</div> |
| 1539 |
<div style="padding-left: 2em;"> <i>expr2</i> – the second expression</div> |
| 1540 |
<div style="padding-left: 2em;"> returns – <code>t</code> if they are equal, <code>nil</code> otherwise<br> |
| 1541 |
|
| 1542 |
</div> |
| 1543 |
|
| 1544 |
</div> |
| 1545 |
<a name = "247"><h3>Control Constructs</h3></a><a name="index1618"></a><div style="padding-left: 0em;"> |
| 1546 |
<code>(cond<a name="index1619"></a> <tt><i>pair</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – evaluate conditionally |
| 1547 |
</div><div style="padding-left: 2em;"> |
| 1548 |
<i>pair</i> – pair consisting of:<br> |
| 1549 |
|
| 1550 |
</div><div style="padding-left: 4em;"> |
| 1551 |
(<i>pred</i> <i>expr</i>...)<br> |
| 1552 |
|
| 1553 |
</div></div> |
| 1554 |
<div style="padding-left: 2em;"> where:<br> |
| 1555 |
|
| 1556 |
</div><div style="padding-left: 4em;"> |
| 1557 |
<i>pred</i> – is a predicate expression</div> |
| 1558 |
<div style="padding-left: 4em;"> <i>expr</i> – evaluated if the predicate<br> |
| 1559 |
|
| 1560 |
is not <code>nil</code><br> |
| 1561 |
|
| 1562 |
</div></div> |
| 1563 |
<div style="padding-left: 2em;">returns – the value of the first expression whose predicate is not <br> |
| 1564 |
|
| 1565 |
<code>nil</code><br> |
| 1566 |
|
| 1567 |
</div> |
| 1568 |
<br> |
| 1569 |
<code>and<a name="index1620"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1570 |
<code>(and <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – the logical and of a list of expressions<br> |
| 1571 |
|
| 1572 |
|
| 1573 |
</div><div style="padding-left: 2em;"> |
| 1574 |
<i>expr</i> – the expressions to be anded</div> |
| 1575 |
<div style="padding-left: 2em;"> returns – <code>nil</code> if any expression evaluates to <code>nil</code>,<br> |
| 1576 |
|
| 1577 |
otherwise the value of the last expression<br> |
| 1578 |
|
| 1579 |
(evaluation of expressions stops after the first<br> |
| 1580 |
|
| 1581 |
expression that evaluates to <code>nil</code>)<br> |
| 1582 |
|
| 1583 |
</div> |
| 1584 |
<br> |
| 1585 |
<code>or<a name="index1621"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1586 |
<code>(or <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – the logical or of a list of expressions<br> |
| 1587 |
|
| 1588 |
|
| 1589 |
</div><div style="padding-left: 2em;"> |
| 1590 |
<i>expr</i> – the expressions to be ored</div> |
| 1591 |
<div style="padding-left: 2em;"> returns – <code>nil</code> if all expressions evaluate to <code>nil</code>,<br> |
| 1592 |
|
| 1593 |
otherwise the value of the first non-<code>nil</code> expression<br> |
| 1594 |
|
| 1595 |
(evaluation of expressions stops after the first<br> |
| 1596 |
|
| 1597 |
expression that does not evaluate to <code>nil</code>)<br> |
| 1598 |
|
| 1599 |
</div> |
| 1600 |
<br> |
| 1601 |
<code>(if<a name="index1622"></a> <tt><i>texpr</i></tt> <tt><i>expr1</i></tt> [<tt><i>expr2</i></tt>])</code> [LISP] – evaluate expressions conditionally. <br> |
| 1602 |
|
| 1603 |
|
| 1604 |
</div><div style="padding-left: 2em;"> |
| 1605 |
<i>texpr</i> – the test expression</div> |
| 1606 |
<div style="padding-left: 2em;"> <i>expr1</i> – the expression to be evaluated if texpr is non-<code>nil</code></div> |
| 1607 |
<div style="padding-left: 2em;"> <i>expr2</i> – the expression to be evaluated if texpr is <code>nil</code> (default is <code>nil</code>)</div> |
| 1608 |
<div style="padding-left: 2em;"> returns – the value of the selected expression.</div> |
| 1609 |
<div style="padding-left: 2em;"> Note that the SAL conditional expression syntax is <code>#?(<i>test</i>, <i>iftrue-expression</i>, <i>iffalse-expression</i>)</code>, but <code>#if</code> may be used instead of <code>#?</code>. Either form may omit the third argument, which defaults to <code>nil</code>.<br> |
| 1610 |
|
| 1611 |
</div> |
| 1612 |
<br> |
| 1613 |
<code>when<a name="index1623"></a>(<i>texpr</i>, <i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1614 |
<code>(when <tt><i>texpr</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – evaluate only when a condition is true<br> |
| 1615 |
|
| 1616 |
|
| 1617 |
</div><div style="padding-left: 2em;"> |
| 1618 |
<i>texpr</i> – the test expression</div> |
| 1619 |
<div style="padding-left: 2em;"> <i>expr</i> – the expression(s) to be evaluated if texpr is non-<code>nil</code></div> |
| 1620 |
<div style="padding-left: 2em;"> returns – the value of the last expression or <code>nil</code><br> |
| 1621 |
|
| 1622 |
</div> |
| 1623 |
<br> |
| 1624 |
<code>unless<a name="index1624"></a>(<i>texpr</i>, <i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1625 |
<code>(unless <tt><i>texpr</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – evaluate only when a condition is false<br> |
| 1626 |
|
| 1627 |
|
| 1628 |
</div><div style="padding-left: 2em;"> |
| 1629 |
<i>texpr</i> – the test expression</div> |
| 1630 |
<div style="padding-left: 2em;"> <i>expr</i> – the expression(s) to be evaluated if texpr is <code>nil</code></div> |
| 1631 |
<div style="padding-left: 2em;"> returns – the value of the last expression or <code>nil</code><br> |
| 1632 |
|
| 1633 |
</div> |
| 1634 |
<br> |
| 1635 |
<code>(case<a name="index1625"></a> <tt><i>expr</i></tt> <tt><i>case</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – select by case |
| 1636 |
</div><div style="padding-left: 2em;"> |
| 1637 |
<i>expr</i> – the selection expression</div> |
| 1638 |
<div style="padding-left: 2em;"> <i>case</i> – pair consisting of:<br> |
| 1639 |
|
| 1640 |
</div><div style="padding-left: 4em;"> |
| 1641 |
(<i>value</i> <i>expr</i>...)<br> |
| 1642 |
|
| 1643 |
</div></div> |
| 1644 |
<div style="padding-left: 2em;"> where:<br> |
| 1645 |
|
| 1646 |
</div><div style="padding-left: 4em;"> |
| 1647 |
<i>value</i> – is a single expression or a list of<br> |
| 1648 |
|
| 1649 |
expressions (unevaluated)</div> |
| 1650 |
<div style="padding-left: 4em;"> <i>expr</i> – are expressions to execute if the<br> |
| 1651 |
|
| 1652 |
case matches<br> |
| 1653 |
|
| 1654 |
</div></div> |
| 1655 |
<div style="padding-left: 2em;"> returns – the value of the last expression of the matching case<br> |
| 1656 |
|
| 1657 |
</div> |
| 1658 |
<br> |
| 1659 |
|
| 1660 |
<code>(let<a name="index1626"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – create local bindings<br> |
| 1661 |
|
| 1662 |
|
| 1663 |
<code>(let*<a name="index1627"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – let with sequential binding<br> |
| 1664 |
|
| 1665 |
|
| 1666 |
</div><div style="padding-left: 2em;"> |
| 1667 |
<i>binding</i> – the variable bindings each of which is either:<br> |
| 1668 |
|
| 1669 |
</div><div style="padding-left: 4em;"> |
| 1670 |
1) a symbol (which is initialized to <code>nil</code>)</div> |
| 1671 |
<div style="padding-left: 4em;"> 2) a list whose car is a symbol and whose cadr<br> |
| 1672 |
|
| 1673 |
is an initialization expression<br> |
| 1674 |
|
| 1675 |
</div></div> |
| 1676 |
<div style="padding-left: 2em;"> <i>expr</i> – the expressions to be evaluated</div> |
| 1677 |
<div style="padding-left: 2em;"> returns – the value of the last expression<br> |
| 1678 |
|
| 1679 |
</div> |
| 1680 |
<br> |
| 1681 |
|
| 1682 |
<code>(flet<a name="index1628"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – create local functions<br> |
| 1683 |
<code>(labels<a name="index1629"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – flet with recursive functions<br> |
| 1684 |
<code>(macrolet<a name="index1630"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – create local macros<br> |
| 1685 |
|
| 1686 |
|
| 1687 |
</div><div style="padding-left: 2em;"> |
| 1688 |
<i>binding</i> – the function bindings each of which is:<br> |
| 1689 |
|
| 1690 |
</div><div style="padding-left: 4em;"> |
| 1691 |
(<i>sym</i> <i>fargs</i> <i>expr</i>...)<br> |
| 1692 |
|
| 1693 |
</div></div> |
| 1694 |
<div style="padding-left: 2em;"> where:<br> |
| 1695 |
|
| 1696 |
</div><div style="padding-left: 4em;"> |
| 1697 |
<i>sym</i> – the function/macro name</div> |
| 1698 |
<div style="padding-left: 4em;"> <i>fargs</i> – formal argument list (lambda list)</div> |
| 1699 |
<div style="padding-left: 4em;"> <i>expr</i> – expressions constituting the body of<br> |
| 1700 |
|
| 1701 |
the function/macro<br> |
| 1702 |
|
| 1703 |
</div></div> |
| 1704 |
<div style="padding-left: 2em;"> <i>expr</i> – the expressions to be evaluated</div> |
| 1705 |
<div style="padding-left: 2em;"> returns – the value of the last expression<br> |
| 1706 |
|
| 1707 |
</div> |
| 1708 |
<br> |
| 1709 |
<code>catch<a name="index1631"></a>(<i>sym</i>, <i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1710 |
<code>(catch <tt><i>sym</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – evaluate expressions and catch throws<br> |
| 1711 |
|
| 1712 |
|
| 1713 |
</div><div style="padding-left: 2em;"> |
| 1714 |
<i>sym</i> – the catch tag</div> |
| 1715 |
<div style="padding-left: 2em;"> <i>expr</i> – expressions to evaluate</div> |
| 1716 |
<div style="padding-left: 2em;"> returns – the value of the last expression the throw expression<br> |
| 1717 |
|
| 1718 |
</div> |
| 1719 |
<br> |
| 1720 |
<code>throw<a name="index1632"></a>(<i>sym</i> [, <i>expr</i>])</code> [SAL]<br> |
| 1721 |
<code>(throw <tt><i>sym</i></tt> [<tt><i>expr</i></tt>])</code> [LISP] – throw to a catch<br> |
| 1722 |
|
| 1723 |
|
| 1724 |
</div><div style="padding-left: 2em;"> |
| 1725 |
<i>sym</i> – the catch tag</div> |
| 1726 |
<div style="padding-left: 2em;"> <i>expr</i> – the value for the catch to return (defaults to <code>nil</code>)</div> |
| 1727 |
<div style="padding-left: 2em;"> returns – never returns<br> |
| 1728 |
|
| 1729 |
</div> |
| 1730 |
<br> |
| 1731 |
<code>unwind-protect<a name="index1633"></a>(<i>expr</i>, <i>cexpr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1732 |
<code>(unwind-protect <tt><i>expr</i></tt> <tt><i>cexpr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – protect evaluation of an expression<br> |
| 1733 |
|
| 1734 |
|
| 1735 |
</div><div style="padding-left: 2em;"> |
| 1736 |
<i>expr</i> – the expression to protect</div> |
| 1737 |
<div style="padding-left: 2em;"> <i>cexpr</i> – the cleanup expressions</div> |
| 1738 |
<div style="padding-left: 2em;"> returns – the value of the expression<br> |
| 1739 |
</div> |
| 1740 |
<div style="padding-left: 2em;"> Note: unwind-protect guarantees to execute the cleanup expressions<br> |
| 1741 |
|
| 1742 |
even if a non-local exit terminates the evaluation of the<br> |
| 1743 |
|
| 1744 |
protected expression<br> |
| 1745 |
|
| 1746 |
</div> |
| 1747 |
|
| 1748 |
</div> |
| 1749 |
<a name = "248"><h3>Looping Constructs</h3></a><a name="index1634"></a><div style="padding-left: 0em;"> |
| 1750 |
<code>(loop<a name="index1635"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – basic looping form |
| 1751 |
</div><div style="padding-left: 2em;"> |
| 1752 |
<i>expr</i> – the body of the loop</div> |
| 1753 |
<div style="padding-left: 2em;"> returns – never returns (must use non-local exit)<br> |
| 1754 |
|
| 1755 |
</div> |
| 1756 |
<br> |
| 1757 |
|
| 1758 |
<code>(do<a name="index1636"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) (<tt><i>texpr</i></tt> <tt><i>rexpr</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 1759 |
|
| 1760 |
|
| 1761 |
<code>(do*<a name="index1637"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) (<tt><i>texpr</i></tt> <tt><i>rexpr</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 1762 |
|
| 1763 |
|
| 1764 |
</div><div style="padding-left: 2em;"> |
| 1765 |
<i>binding</i> – the variable bindings each of which is either:<br> |
| 1766 |
|
| 1767 |
</div><div style="padding-left: 4em;"> |
| 1768 |
1) a symbol (which is initialized to <code>nil</code>)</div> |
| 1769 |
<div style="padding-left: 4em;"> 2) a list of the form: (<i>sym</i> <i>init</i> [<i>step</i>])<br> |
| 1770 |
|
| 1771 |
where:<br> |
| 1772 |
|
| 1773 |
</div><div style="padding-left: 6em;"> |
| 1774 |
<i>sym</i> – is the symbol to bind</div> |
| 1775 |
<div style="padding-left: 6em;"> <i>init</i> – is the initial value of the symbol</div> |
| 1776 |
<div style="padding-left: 6em;"> <i>step</i> – is a step expression<br> |
| 1777 |
|
| 1778 |
</div></div></div> |
| 1779 |
<div style="padding-left: 2em;"> <i>texpr</i> – the termination test expression</div> |
| 1780 |
<div style="padding-left: 2em;"> <i>rexpr</i> – result expressions (the default is <code>nil</code>)</div> |
| 1781 |
<div style="padding-left: 2em;"> <i>expr</i> – the body of the loop (treated like an implicit prog)</div> |
| 1782 |
<div style="padding-left: 2em;"> returns – the value of the last result expression<br> |
| 1783 |
|
| 1784 |
</div> |
| 1785 |
<br> |
| 1786 |
<code>(dolist<a name="index1638"></a> (<tt><i>sym</i></tt> <tt><i>expr</i></tt> [<tt><i>rexpr</i></tt>]) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – loop through a list |
| 1787 |
</div><div style="padding-left: 2em;"> |
| 1788 |
<i>sym</i> – the symbol to bind to each list element</div> |
| 1789 |
<div style="padding-left: 2em;"> <i>expr</i> – the list expression</div> |
| 1790 |
<div style="padding-left: 2em;"> <i>rexpr</i> – the result expression (the default is <code>nil</code>)</div> |
| 1791 |
<div style="padding-left: 2em;"> <i>expr</i> – the body of the loop (treated like an implicit prog)<br> |
| 1792 |
|
| 1793 |
</div> |
| 1794 |
<br> |
| 1795 |
<code>(dotimes<a name="index1639"></a> (<tt><i>sym</i></tt> <tt><i>expr</i></tt> [<tt><i>rexpr</i></tt>]) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – loop from zero to n-1 |
| 1796 |
</div><div style="padding-left: 2em;"> |
| 1797 |
<i>sym</i> – the symbol to bind to each value from 0 to n-1</div> |
| 1798 |
<div style="padding-left: 2em;"> <i>expr</i> – the number of times to loop</div> |
| 1799 |
<div style="padding-left: 2em;"> <i>rexpr</i> – the result expression (the default is <code>nil</code>)</div> |
| 1800 |
<div style="padding-left: 2em;"> <i>expr</i> – the body of the loop (treated like an implicit prog)<br> |
| 1801 |
|
| 1802 |
</div> |
| 1803 |
|
| 1804 |
</div> |
| 1805 |
<a name = "249"><h3>The Program Feature</h3></a><a name="index1640"></a><div style="padding-left: 0em;"> |
| 1806 |
|
| 1807 |
<code>(prog<a name="index1641"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – the program feature<br> |
| 1808 |
|
| 1809 |
|
| 1810 |
<code>(prog*<a name="index1642"></a> (<tt><i>binding</i></tt><span style="font-style:normal">...</span>) <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – prog with sequential binding<br> |
| 1811 |
|
| 1812 |
|
| 1813 |
</div><div style="padding-left: 2em;"> |
| 1814 |
<i>binding</i> – the variable bindings each of which is either:<br> |
| 1815 |
|
| 1816 |
</div><div style="padding-left: 4em;"> |
| 1817 |
1) a symbol (which is initialized to <code>nil</code>)</div> |
| 1818 |
<div style="padding-left: 4em;"> 2) a list whose car is a symbol and whose cadr<br> |
| 1819 |
|
| 1820 |
is an initialization expression<br> |
| 1821 |
|
| 1822 |
</div></div> |
| 1823 |
<div style="padding-left: 2em;"> <i>expr</i> – expressions to evaluate or tags (symbols)</div> |
| 1824 |
<div style="padding-left: 2em;"> returns – <code>nil</code> or the argument passed to the return function<br> |
| 1825 |
|
| 1826 |
</div> |
| 1827 |
<br> |
| 1828 |
<code>block(<i>name</i>, <i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1829 |
<code>(block<a name="index1643"></a> <tt><i>name</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – named block<br> |
| 1830 |
|
| 1831 |
|
| 1832 |
</div><div style="padding-left: 2em;"> |
| 1833 |
<i>name</i> – the block name (symbol)</div> |
| 1834 |
<div style="padding-left: 2em;"> <i>expr</i> – the block body</div> |
| 1835 |
<div style="padding-left: 2em;"> returns – the value of the last expression<br> |
| 1836 |
|
| 1837 |
</div> |
| 1838 |
<br> |
| 1839 |
<code>(return<a name="index1644"></a> [<tt><i>expr</i></tt>])</code> [LISP] – cause a prog construct to return a value |
| 1840 |
</div><div style="padding-left: 2em;"> |
| 1841 |
<i>expr</i> – the value (defaults to <code>nil</code>)</div> |
| 1842 |
<div style="padding-left: 2em;"> returns – never returns<br> |
| 1843 |
|
| 1844 |
</div> |
| 1845 |
<br> |
| 1846 |
<code>return-from<a name="index1645"></a>(<i>name</i> [, <i>value</i>])</code> [SAL]<br> |
| 1847 |
<code>(return-from <tt><i>name</i></tt> [<tt><i>value</i></tt>])</code> [LISP] – return from a named block<br> |
| 1848 |
|
| 1849 |
|
| 1850 |
</div><div style="padding-left: 2em;"> |
| 1851 |
<i>name</i> – the block name (symbol)</div> |
| 1852 |
<div style="padding-left: 2em;"> <i>value</i> – the value to return (defaults to <code>nil</code>)</div> |
| 1853 |
<div style="padding-left: 2em;"> returns – never returns<br> |
| 1854 |
|
| 1855 |
</div> |
| 1856 |
<br> |
| 1857 |
<code>tagbody<a name="index1646"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1858 |
<code>(tagbody <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – block with labels<br> |
| 1859 |
|
| 1860 |
|
| 1861 |
</div><div style="padding-left: 2em;"> |
| 1862 |
<i>expr</i> – expression(s) to evaluate or tags (symbols)</div> |
| 1863 |
<div style="padding-left: 2em;"> returns – <code>nil</code><br> |
| 1864 |
|
| 1865 |
</div> |
| 1866 |
<br> |
| 1867 |
<code>go<a name="index1647"></a>(<i>sym</i>)</code> [SAL]<br> |
| 1868 |
<code>(go <tt><i>sym</i></tt>)</code> [LISP] – go to a tag within a tagbody or prog<br> |
| 1869 |
|
| 1870 |
|
| 1871 |
</div><div style="padding-left: 2em;"> |
| 1872 |
<i>sym</i> – the tag (quoted)</div> |
| 1873 |
<div style="padding-left: 2em;"> returns – never returns<br> |
| 1874 |
|
| 1875 |
</div> |
| 1876 |
<br> |
| 1877 |
<code>(progv<a name="index1648"></a> <tt><i>slist</i></tt> <tt><i>vlist</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – dynamically bind symbols |
| 1878 |
</div><div style="padding-left: 2em;"> |
| 1879 |
<i>slist</i> – list of symbols</div> |
| 1880 |
<div style="padding-left: 2em;"> <i>vlist</i> – list of values to bind to the symbols</div> |
| 1881 |
<div style="padding-left: 2em;"> <i>expr</i> – expression(s) to evaluate</div> |
| 1882 |
<div style="padding-left: 2em;"> returns – the value of the last expression<br> |
| 1883 |
|
| 1884 |
</div> |
| 1885 |
<br> |
| 1886 |
<code>prog1(<i>expr1</i>, <i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1887 |
<code>(prog1<a name="index1649"></a> <tt><i>expr1</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – execute expressions sequentially<br> |
| 1888 |
|
| 1889 |
|
| 1890 |
</div><div style="padding-left: 2em;"> |
| 1891 |
<i>expr1</i> – the first expression to evaluate</div> |
| 1892 |
<div style="padding-left: 2em;"> <i>expr</i> – the remaining expressions to evaluate</div> |
| 1893 |
<div style="padding-left: 2em;"> returns – the value of the first expression<br> |
| 1894 |
|
| 1895 |
</div> |
| 1896 |
<br> |
| 1897 |
<code>prog2(<i>expr1</i>, <i>expr2</i>, <i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1898 |
<code>(prog2<a name="index1650"></a> <tt><i>expr1</i></tt> <tt><i>expr2</i></tt> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – execute expressions sequentially<br> |
| 1899 |
|
| 1900 |
|
| 1901 |
</div><div style="padding-left: 2em;"> |
| 1902 |
<i>expr1</i> – the first expression to evaluate</div> |
| 1903 |
<div style="padding-left: 2em;"> <i>expr2</i> – the second expression to evaluate</div> |
| 1904 |
<div style="padding-left: 2em;"> <i>expr</i> – the remaining expressions to evaluate</div> |
| 1905 |
<div style="padding-left: 2em;"> returns – the value of the second expression<br> |
| 1906 |
|
| 1907 |
</div> |
| 1908 |
<br> |
| 1909 |
<code>progn(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 1910 |
<code>(progn<a name="index1651"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – execute expressions sequentially<br> |
| 1911 |
|
| 1912 |
|
| 1913 |
</div><div style="padding-left: 2em;"> |
| 1914 |
<i>expr</i> – the expressions to evaluate</div> |
| 1915 |
<div style="padding-left: 2em;"> returns – the value of the last expression (or <code>nil</code>)<br> |
| 1916 |
|
| 1917 |
</div> |
| 1918 |
|
| 1919 |
</div> |
| 1920 |
<a name = "250"><h3>Debugging and Error Handling</h3></a><a name="index1652"></a><a name="index1653"></a><div style="padding-left: 0em;"> |
| 1921 |
<code>trace<a name="index1654"></a>(<i>sym</i>)</code> [SAL]<br> |
| 1922 |
<code>(trace <tt><i>sym</i></tt>)</code> [LISP] – add a function to the trace list<br> |
| 1923 |
|
| 1924 |
|
| 1925 |
</div><div style="padding-left: 2em;"> |
| 1926 |
<i>sym</i> – the function to add (quoted)</div> |
| 1927 |
<div style="padding-left: 2em;"> returns – the trace list<br> |
| 1928 |
|
| 1929 |
</div> |
| 1930 |
<br> |
| 1931 |
<code>untrace<a name="index1655"></a>(<i>sym</i>)</code> [SAL]<br> |
| 1932 |
<code>(untrace <tt><i>sym</i></tt>)</code> [LISP] – remove a function from the trace list<br> |
| 1933 |
|
| 1934 |
|
| 1935 |
</div><div style="padding-left: 2em;"> |
| 1936 |
<i>sym</i> – the function to remove (quoted)</div> |
| 1937 |
<div style="padding-left: 2em;"> returns – the trace list<br> |
| 1938 |
|
| 1939 |
</div> |
| 1940 |
<br> |
| 1941 |
<code>error<a name="index1656"></a>(<i>emsg</i> [, <i>arg</i>])</code> [SAL]<br> |
| 1942 |
<code>(error <tt><i>emsg</i></tt> [<tt><i>arg</i></tt>])</code> [LISP] – signal a non-correctable error<br> |
| 1943 |
|
| 1944 |
|
| 1945 |
</div><div style="padding-left: 2em;"> |
| 1946 |
<i>emsg</i> – the error message string</div> |
| 1947 |
<div style="padding-left: 2em;"> <i>arg</i> – the argument expression (printed after the message)</div> |
| 1948 |
<div style="padding-left: 2em;"> returns – never returns<br> |
| 1949 |
|
| 1950 |
</div> |
| 1951 |
<br> |
| 1952 |
<code>cerror<a name="index1657"></a>(<i>cmsg</i>, <i>emsg</i> [, <i>arg</i>])</code> [SAL]<br> |
| 1953 |
<code>(cerror <tt><i>cmsg</i></tt> <tt><i>emsg</i></tt> [<tt><i>arg</i></tt>])</code> [LISP] – signal a correctable error<br> |
| 1954 |
|
| 1955 |
|
| 1956 |
</div><div style="padding-left: 2em;"> |
| 1957 |
<i>cmsg</i> – the continue message string</div> |
| 1958 |
<div style="padding-left: 2em;"> <i>emsg</i> – the error message string</div> |
| 1959 |
<div style="padding-left: 2em;"> <i>arg</i> – the argument expression (printed after the message)</div> |
| 1960 |
<div style="padding-left: 2em;"> returns – <code>nil</code> when continued from the break loop<br> |
| 1961 |
|
| 1962 |
</div> |
| 1963 |
<br> |
| 1964 |
<code>break<a name="index1658"></a>([<i>bmsg</i> [, <i>arg</i>]])</code> [SAL]<br> |
| 1965 |
<code>(break [<tt><i>bmsg</i></tt> [<tt><i>arg</i></tt>]])</code> [LISP] – enter a break loop<br> |
| 1966 |
|
| 1967 |
|
| 1968 |
</div><div style="padding-left: 2em;"> |
| 1969 |
<i>bmsg</i> – the break message string (defaults to <code>**break**</code>)</div> |
| 1970 |
<div style="padding-left: 2em;"> <i>arg</i> – the argument expression (printed after the message)</div> |
| 1971 |
<div style="padding-left: 2em;"> returns – <code>nil</code> when continued from the break loop<br> |
| 1972 |
|
| 1973 |
</div> |
| 1974 |
<br> |
| 1975 |
<code>(clean-up<a name="index1659"></a>)</code> [LISP] – clean-up after an error |
| 1976 |
</div><div style="padding-left: 2em;"> |
| 1977 |
returns – never returns<br> |
| 1978 |
|
| 1979 |
</div> |
| 1980 |
<br> |
| 1981 |
<code>(top-level<a name="index1660"></a>)</code> [LISP] – clean-up after an error and return to the top level |
| 1982 |
</div><div style="padding-left: 2em;"> |
| 1983 |
returns – never returns<br> |
| 1984 |
|
| 1985 |
</div> |
| 1986 |
<br> |
| 1987 |
<code>(continue<a name="index1661"></a>)</code> [LISP] – continue from a correctable error |
| 1988 |
</div><div style="padding-left: 2em;"> |
| 1989 |
returns – never returns<br> |
| 1990 |
|
| 1991 |
</div> |
| 1992 |
<br> |
| 1993 |
<code>(errset<a name="index1662"></a> <tt><i>expr</i></tt> [<tt><i>pflag</i></tt>])</code> [LISP] – trap errors |
| 1994 |
</div><div style="padding-left: 2em;"> |
| 1995 |
<i>expr</i> – the expression to execute</div> |
| 1996 |
<div style="padding-left: 2em;"> <i>pflag</i> – flag to control printing of the error message</div> |
| 1997 |
<div style="padding-left: 2em;"> returns – the value of the last expression consed with <code>nil</code></div> |
| 1998 |
<div style="padding-left: 2em;"> or <code>nil</code> on error<br> |
| 1999 |
|
| 2000 |
</div> |
| 2001 |
<br> |
| 2002 |
<code>(baktrace<a name="index1663"></a><a name="index1664"></a><a name="index1665"></a> [<tt><i>n</i></tt>])</code> [LISP] – print n levels of trace back information |
| 2003 |
</div><div style="padding-left: 2em;"> |
| 2004 |
<i>n</i> – the number of levels (defaults to all levels)</div> |
| 2005 |
<div style="padding-left: 2em;"> returns – <code>nil</code><br> |
| 2006 |
|
| 2007 |
</div> |
| 2008 |
<br> |
| 2009 |
<code>(evalhook<a name="index1666"></a> <tt><i>expr</i></tt> <tt><i>ehook</i></tt> <tt><i>ahook</i></tt> [<tt><i>env</i></tt>])</code> [LISP] – evaluate with hooks |
| 2010 |
</div><div style="padding-left: 2em;"> |
| 2011 |
<i>expr</i> – the expression to evaluate</div> |
| 2012 |
<div style="padding-left: 2em;"> <i>ehook</i> – the value for <code>*evalhook*</code></div> |
| 2013 |
<div style="padding-left: 2em;"> <i>ahook</i> – the value for <code>*applyhook*</code></div> |
| 2014 |
<div style="padding-left: 2em;"> <i>env</i> – the environment (default is <code>nil</code>)</div> |
| 2015 |
<div style="padding-left: 2em;"> returns – the result of evaluating the expression<br> |
| 2016 |
|
| 2017 |
</div> |
| 2018 |
<br> |
| 2019 |
<code>profile(<i>flag</i>)</code> [SAL]<br> |
| 2020 |
<code>(profile<a name="index1667"></a> <tt><i>flag</i></tt>)</code> [LISP] – turn profiling on or off.<br> |
| 2021 |
|
| 2022 |
|
| 2023 |
</div><div style="padding-left: 2em;"> |
| 2024 |
<i>flag</i> – <code>nil</code> turns profiling off, otherwise on</div> |
| 2025 |
<div style="padding-left: 2em;"> returns – the previous state of profiling.</div> |
| 2026 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 2027 |
|
| 2028 |
</div> |
| 2029 |
|
| 2030 |
</div> |
| 2031 |
<a name = "251"><h3>Arithmetic Functions</h3></a><a name="index1668"></a><div style="padding-left: 0em;"> |
| 2032 |
<code>truncate<a name="index1669"></a><a name="index1670"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2033 |
<code>(truncate <tt><i>expr</i></tt>)</code> [LISP] – truncates a floating point number to an integer<br> |
| 2034 |
|
| 2035 |
|
| 2036 |
</div><div style="padding-left: 2em;"> |
| 2037 |
<i>expr</i> – the number</div> |
| 2038 |
<div style="padding-left: 2em;"> returns – the result of truncating the number<br> |
| 2039 |
|
| 2040 |
</div> |
| 2041 |
<br> |
| 2042 |
<code>float<a name="index1671"></a><a name="index1672"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2043 |
<code>(float <tt><i>expr</i></tt>)</code> [LISP] – converts an integer to a floating point number<br> |
| 2044 |
|
| 2045 |
|
| 2046 |
</div><div style="padding-left: 2em;"> |
| 2047 |
<i>expr</i> – the number</div> |
| 2048 |
<div style="padding-left: 2em;"> returns – the result of floating the integer<br> |
| 2049 |
|
| 2050 |
</div> |
| 2051 |
<br> |
| 2052 |
<code>(+<a name="index1673"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – add a list of numbers |
| 2053 |
</div><div style="padding-left: 2em;"> |
| 2054 |
<i>expr</i> – the numbers</div> |
| 2055 |
<div style="padding-left: 2em;"> returns – the result of the addition<br> |
| 2056 |
|
| 2057 |
</div> |
| 2058 |
<br> |
| 2059 |
<code>(-<a name="index1674"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – subtract a list of numbers or negate a single number |
| 2060 |
</div><div style="padding-left: 2em;"> |
| 2061 |
<i>expr</i> – the numbers</div> |
| 2062 |
<div style="padding-left: 2em;"> returns – the result of the subtraction<br> |
| 2063 |
|
| 2064 |
</div> |
| 2065 |
<br> |
| 2066 |
<code>(*<a name="index1675"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – multiply a list of numbers |
| 2067 |
</div><div style="padding-left: 2em;"> |
| 2068 |
<i>expr</i> – the numbers</div> |
| 2069 |
<div style="padding-left: 2em;"> returns – the result of the multiplication<br> |
| 2070 |
|
| 2071 |
</div> |
| 2072 |
<br> |
| 2073 |
<code>(/<a name="index1676"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – divide a list of numbers |
| 2074 |
</div><div style="padding-left: 2em;"> |
| 2075 |
<i>expr</i> – the numbers</div> |
| 2076 |
<div style="padding-left: 2em;"> returns – the result of the division<br> |
| 2077 |
|
| 2078 |
</div> |
| 2079 |
<br> |
| 2080 |
<code>(1+<a name="index1677"></a> <tt><i>expr</i></tt>)</code> [LISP] – add one to a number |
| 2081 |
</div><div style="padding-left: 2em;"> |
| 2082 |
<i>expr</i> – the number</div> |
| 2083 |
<div style="padding-left: 2em;"> returns – the number plus one<br> |
| 2084 |
|
| 2085 |
</div> |
| 2086 |
<br> |
| 2087 |
<code>(1-<a name="index1678"></a> <tt><i>expr</i></tt>)</code> [LISP] – subtract one from a number |
| 2088 |
</div><div style="padding-left: 2em;"> |
| 2089 |
<i>expr</i> – the number</div> |
| 2090 |
<div style="padding-left: 2em;"> returns – the number minus one<br> |
| 2091 |
|
| 2092 |
</div> |
| 2093 |
<br> |
| 2094 |
<code>rem<a name="index1679"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2095 |
<code>(rem<a name="index1680"></a><a name="index1681"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – remainder of a list of numbers<br> |
| 2096 |
|
| 2097 |
|
| 2098 |
</div><div style="padding-left: 2em;"> |
| 2099 |
<i>expr</i> – the numbers</div> |
| 2100 |
<div style="padding-left: 2em;"> returns – the result of the remainder operation<br> |
| 2101 |
|
| 2102 |
</div> |
| 2103 |
<br> |
| 2104 |
<code>min<a name="index1682"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2105 |
<code>(min<a name="index1683"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – the smallest of a list of numbers<br> |
| 2106 |
|
| 2107 |
|
| 2108 |
</div><div style="padding-left: 2em;"> |
| 2109 |
<i>expr</i> – the expressions to be checked</div> |
| 2110 |
<div style="padding-left: 2em;"> returns – the smallest number in the list<br> |
| 2111 |
|
| 2112 |
</div> |
| 2113 |
<br> |
| 2114 |
<code>max<a name="index1684"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2115 |
<code>(max<a name="index1685"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – the largest of a list of numbers<br> |
| 2116 |
|
| 2117 |
|
| 2118 |
</div><div style="padding-left: 2em;"> |
| 2119 |
<i>expr</i> – the expressions to be checked</div> |
| 2120 |
<div style="padding-left: 2em;"> returns – the largest number in the list<br> |
| 2121 |
|
| 2122 |
</div> |
| 2123 |
<br> |
| 2124 |
<code>abs<a name="index1686"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2125 |
<code>(abs <tt><i>expr</i></tt>)</code> [LISP] – the absolute value of a number<br> |
| 2126 |
|
| 2127 |
|
| 2128 |
</div><div style="padding-left: 2em;"> |
| 2129 |
<i>expr</i> – the number</div> |
| 2130 |
<div style="padding-left: 2em;"> returns – the absolute value of the number<br> |
| 2131 |
|
| 2132 |
</div> |
| 2133 |
<br> |
| 2134 |
<code>gcd<a name="index1687"></a>(<i>n1</i>, <i>n2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2135 |
<code>(gcd <tt><i>n1</i></tt> <tt><i>n2</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – compute the greatest common divisor<br> |
| 2136 |
|
| 2137 |
|
| 2138 |
</div><div style="padding-left: 2em;"> |
| 2139 |
<i>n1</i> – the first number (integer)</div> |
| 2140 |
<div style="padding-left: 2em;"> <i>n2</i> – the second number(s) (integer)</div> |
| 2141 |
<div style="padding-left: 2em;"> returns – the greatest common divisor<br> |
| 2142 |
|
| 2143 |
</div> |
| 2144 |
<br> |
| 2145 |
<code>random<a name="index1688"></a>(<i>n</i>)</code> [SAL]<br> |
| 2146 |
<code>(random <tt><i>n</i></tt>)</code> [LISP] – compute a random number between 0 and |n|-1 inclusive. If n is 0, return 0.<br> |
| 2147 |
|
| 2148 |
|
| 2149 |
</div><div style="padding-left: 2em;"> |
| 2150 |
<i>n</i> – the upper bound (integer)</div> |
| 2151 |
<div style="padding-left: 2em;"> returns – a random number<br> |
| 2152 |
|
| 2153 |
</div> |
| 2154 |
<br> |
| 2155 |
<code>rrandom<a name="index1689"></a>()</code> [SAL]<br> |
| 2156 |
<code>(rrandom<a name="index1690"></a>)</code> [LISP] – compute a random real number between 0 and 1 inclusive<br> |
| 2157 |
|
| 2158 |
|
| 2159 |
</div><div style="padding-left: 2em;"> |
| 2160 |
returns – a random floating point number<br> |
| 2161 |
|
| 2162 |
</div> |
| 2163 |
<br> |
| 2164 |
<code>random-seed<a name="index1691"></a>(<i>n</i>)</code> [SAL]<br> |
| 2165 |
<code>(random-seed<a name="index1692"></a> <tt><i>n</i></tt>)</code> [LISP] – seed the random number generator with starting seed <i>n</i>. If <code>random-seed</code> is not called, <code>sranddev</code> or some other initialization method will be used by default.<br> |
| 2166 |
|
| 2167 |
|
| 2168 |
</div><div style="padding-left: 2em;"> |
| 2169 |
<i>n</i> – the upper bound (integer)</div> |
| 2170 |
<div style="padding-left: 2em;"> returns – a random number<br> |
| 2171 |
|
| 2172 |
</div> |
| 2173 |
<br> |
| 2174 |
<code>sin<a name="index1693"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2175 |
<code>(sin <tt><i>expr</i></tt>)</code> [LISP] – compute the sine of a number<br> |
| 2176 |
|
| 2177 |
|
| 2178 |
</div><div style="padding-left: 2em;"> |
| 2179 |
<i>expr</i> – the floating point number</div> |
| 2180 |
<div style="padding-left: 2em;"> returns – the sine of the number<br> |
| 2181 |
|
| 2182 |
</div> |
| 2183 |
<br> |
| 2184 |
<code>cos<a name="index1694"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2185 |
<code>(cos <tt><i>expr</i></tt>)</code> [LISP] – compute the cosine of a number<br> |
| 2186 |
|
| 2187 |
|
| 2188 |
</div><div style="padding-left: 2em;"> |
| 2189 |
<i>expr</i> – the floating point number</div> |
| 2190 |
<div style="padding-left: 2em;"> returns – the cosine of the number<br> |
| 2191 |
|
| 2192 |
</div> |
| 2193 |
<br> |
| 2194 |
<code>tan<a name="index1695"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2195 |
<code>(tan <tt><i>expr</i></tt>)</code> [LISP] – compute the tangent of a number<br> |
| 2196 |
|
| 2197 |
|
| 2198 |
</div><div style="padding-left: 2em;"> |
| 2199 |
<i>expr</i> – the floating point number</div> |
| 2200 |
<div style="padding-left: 2em;"> returns – the tangent of the number<br> |
| 2201 |
|
| 2202 |
</div> |
| 2203 |
<br> |
| 2204 |
<code>atan<a name="index1696"></a>(<i>expr</i> [, <i>expr2</i>])</code> [SAL]<br> |
| 2205 |
<code>(atan <tt><i>expr</i></tt> [<tt><i>expr2</i></tt>])</code> [LISP] – compute the arctangent<br> |
| 2206 |
|
| 2207 |
|
| 2208 |
</div><div style="padding-left: 2em;"> |
| 2209 |
<i>expr</i> – the value of <i>x</i></div> |
| 2210 |
<div style="padding-left: 2em;"> <i>expr2</i> – the value of <i>y</i> (default value is 1.0)</div> |
| 2211 |
<div style="padding-left: 2em;"> returns – the arctangent of <i>x</i>/<i>y</i></div> |
| 2212 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 2213 |
|
| 2214 |
</div> |
| 2215 |
<br> |
| 2216 |
<code>expt<a name="index1697"></a>(<i>x-expr</i>, <i>y-expr</i>)</code> [SAL]<br> |
| 2217 |
<code>(expt <tt><i>x-expr</i></tt> <tt><i>y-expr</i></tt>)</code> [LISP] – compute x to the y power<br> |
| 2218 |
|
| 2219 |
|
| 2220 |
</div><div style="padding-left: 2em;"> |
| 2221 |
<i>x-expr</i> – the floating point number</div> |
| 2222 |
<div style="padding-left: 2em;"> <i>y-expr</i> – the floating point exponent</div> |
| 2223 |
<div style="padding-left: 2em;"> returns – x to the y power<br> |
| 2224 |
|
| 2225 |
</div> |
| 2226 |
<br> |
| 2227 |
<code>exp<a name="index1698"></a>(<i>x-expr</i>)</code> [SAL]<br> |
| 2228 |
<code>(exp <tt><i>x-expr</i></tt>)</code> [LISP] – compute e to the x power<br> |
| 2229 |
|
| 2230 |
|
| 2231 |
</div><div style="padding-left: 2em;"> |
| 2232 |
<i>x-expr</i> – the floating point number</div> |
| 2233 |
<div style="padding-left: 2em;"> returns – e to the x power<br> |
| 2234 |
|
| 2235 |
</div> |
| 2236 |
<br> |
| 2237 |
<code>sqrt<a name="index1699"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2238 |
<code>(sqrt <tt><i>expr</i></tt>)</code> [LISP] – compute the square root of a number<br> |
| 2239 |
|
| 2240 |
|
| 2241 |
</div><div style="padding-left: 2em;"> |
| 2242 |
<i>expr</i> – the floating point number</div> |
| 2243 |
<div style="padding-left: 2em;"> returns – the square root of the number<br> |
| 2244 |
|
| 2245 |
</div> |
| 2246 |
<br> |
| 2247 |
|
| 2248 |
<code>(<<a name="index1700"></a> <tt><i>n1</i></tt> <tt><i>n2</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – test for less than<br> |
| 2249 |
<code>(<=<a name="index1701"></a> <tt><i>n1</i></tt> <tt><i>n2</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – test for less than or equal to<br> |
| 2250 |
<code>(=<a name="index1702"></a> <tt><i>n1</i></tt> <tt><i>n2</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – test for equal to<br> |
| 2251 |
<code>(/=<a name="index1703"></a> <tt><i>n1</i></tt> <tt><i>n2</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – test for not equal to<br> |
| 2252 |
<code>(>=<a name="index1704"></a> <tt><i>n1</i></tt> <tt><i>n2</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – test for greater than or equal to<br> |
| 2253 |
<code>(><a name="index1705"></a> <tt><i>n1</i></tt> <tt><i>n2</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – test for greater than<br> |
| 2254 |
|
| 2255 |
|
| 2256 |
</div><div style="padding-left: 2em;"> |
| 2257 |
<i>n1</i> – the first number to compare</div> |
| 2258 |
<div style="padding-left: 2em;"> <i>n2</i> – the second number to compare</div> |
| 2259 |
<div style="padding-left: 2em;">returns – <code>t</code> if all arguments are numbers and the results of comparing <i>n1</i> with <i>n2</i>,<br> |
| 2260 |
|
| 2261 |
<i>n2</i> with <i>n3</i>, etc., are all true. (FIXNUMS are converted to FLONUMS in mixed-type comparisons.)<br> |
| 2262 |
|
| 2263 |
</div> |
| 2264 |
|
| 2265 |
</div> |
| 2266 |
<a name = "252"><h3>Bitwise Logical Functions</h3></a><a name="index1706"></a><div style="padding-left: 0em;"> |
| 2267 |
<code>logand<a name="index1707"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2268 |
<code>(logand <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – the bitwise and of a list of numbers<br> |
| 2269 |
|
| 2270 |
|
| 2271 |
</div><div style="padding-left: 2em;"> |
| 2272 |
<i>expr</i> – the numbers</div> |
| 2273 |
<div style="padding-left: 2em;"> returns – the result of the and operation<br> |
| 2274 |
|
| 2275 |
</div> |
| 2276 |
<br> |
| 2277 |
<code>logior<a name="index1708"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2278 |
<code>(logior <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – the bitwise inclusive or of a list of numbers<br> |
| 2279 |
|
| 2280 |
|
| 2281 |
</div><div style="padding-left: 2em;"> |
| 2282 |
<i>expr</i> – the numbers</div> |
| 2283 |
<div style="padding-left: 2em;"> returns – the result of the inclusive or operation<br> |
| 2284 |
|
| 2285 |
</div> |
| 2286 |
<br> |
| 2287 |
<code>logxor<a name="index1709"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2288 |
<code>(logxor <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – the bitwise exclusive or of a list of numbers<br> |
| 2289 |
|
| 2290 |
|
| 2291 |
</div><div style="padding-left: 2em;"> |
| 2292 |
<i>expr</i> – the numbers</div> |
| 2293 |
<div style="padding-left: 2em;"> returns – the result of the exclusive or operation<br> |
| 2294 |
|
| 2295 |
</div> |
| 2296 |
<br> |
| 2297 |
<code>lognot<a name="index1710"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2298 |
<code>(lognot <tt><i>expr</i></tt>)</code> [LISP] – the bitwise not of a number<br> |
| 2299 |
|
| 2300 |
|
| 2301 |
</div><div style="padding-left: 2em;"> |
| 2302 |
<i>expr</i> – the number</div> |
| 2303 |
<div style="padding-left: 2em;"> returns – the bitwise inversion of number<br> |
| 2304 |
|
| 2305 |
</div> |
| 2306 |
|
| 2307 |
</div> |
| 2308 |
<a name = "253"><h3>String Functions</h3></a><a name="index1711"></a><div style="padding-left: 0em;"> |
| 2309 |
<code>string<a name="index1712"></a><a name="index1713"></a><a name="index1714"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2310 |
<code>(string <tt><i>expr</i></tt>)</code> [LISP] – make a string from a value<br> |
| 2311 |
|
| 2312 |
|
| 2313 |
</div><div style="padding-left: 2em;"> |
| 2314 |
<i>expr</i> – an integer (which is first converted into its ASCII character value), string, character, or symbol</div> |
| 2315 |
<div style="padding-left: 2em;"> returns – the string representation of the argument<br> |
| 2316 |
|
| 2317 |
</div> |
| 2318 |
<br> |
| 2319 |
<code>string-search<a name="index1715"></a>(<i>pat</i>, <i>str</i>, start: <i>start</i>, end: <i>end</i>)</code> [SAL]<br> |
| 2320 |
<code>(string-search<a name="index1716"></a> <tt><i>pat</i></tt> <tt><i>str</i></tt> <tt>&key </tt><tt>:start</tt> <tt>:end</tt>)</code> [LISP] – search for pattern in string<br> |
| 2321 |
|
| 2322 |
|
| 2323 |
</div><div style="padding-left: 2em;"> |
| 2324 |
<i>pat</i> – a string to search for</div> |
| 2325 |
<div style="padding-left: 2em;"> <i>str</i> – the string to be searched</div> |
| 2326 |
<div style="padding-left: 2em;"> :start – the starting offset in str</div> |
| 2327 |
<div style="padding-left: 2em;"> :end – the ending offset + 1</div> |
| 2328 |
<div style="padding-left: 2em;"> returns – index of pat in str or NIL if not found</div> |
| 2329 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 2330 |
|
| 2331 |
</div> |
| 2332 |
<br> |
| 2333 |
<code>string-trim<a name="index1717"></a>(<i>bag</i>, <i>str</i>)</code> [SAL]<br> |
| 2334 |
<code>(string-trim <tt><i>bag</i></tt> <tt><i>str</i></tt>)</code> [LISP] – trim both ends of a string<br> |
| 2335 |
|
| 2336 |
|
| 2337 |
</div><div style="padding-left: 2em;"> |
| 2338 |
<i>bag</i> – a string containing characters to trim</div> |
| 2339 |
<div style="padding-left: 2em;"> <i>str</i> – the string to trim</div> |
| 2340 |
<div style="padding-left: 2em;"> returns – a trimed copy of the string<br> |
| 2341 |
|
| 2342 |
</div> |
| 2343 |
<br> |
| 2344 |
<code>string-left-trim<a name="index1718"></a>(<i>bag</i>, <i>str</i>)</code> [SAL]<br> |
| 2345 |
<code>(string-left-trim <tt><i>bag</i></tt> <tt><i>str</i></tt>)</code> [LISP] – trim the left end of a string<br> |
| 2346 |
|
| 2347 |
|
| 2348 |
</div><div style="padding-left: 2em;"> |
| 2349 |
<i>bag</i> – a string containing characters to trim</div> |
| 2350 |
<div style="padding-left: 2em;"> <i>str</i> – the string to trim</div> |
| 2351 |
<div style="padding-left: 2em;"> returns – a trimed copy of the string<br> |
| 2352 |
|
| 2353 |
</div> |
| 2354 |
<br> |
| 2355 |
<code>string-right-trim<a name="index1719"></a>(<i>bag</i>, <i>str</i>)</code> [SAL]<br> |
| 2356 |
<code>(string-right-trim <tt><i>bag</i></tt> <tt><i>str</i></tt>)</code> [LISP] – trim the right end of a string<br> |
| 2357 |
|
| 2358 |
|
| 2359 |
</div><div style="padding-left: 2em;"> |
| 2360 |
<i>bag</i> – a string containing characters to trim</div> |
| 2361 |
<div style="padding-left: 2em;"> <i>str</i> – the string to trim</div> |
| 2362 |
<div style="padding-left: 2em;"> returns – a trimed copy of the string<br> |
| 2363 |
|
| 2364 |
</div> |
| 2365 |
<br> |
| 2366 |
<code>string-upcase<a name="index1720"></a>(<i>str</i>, start: <i>start</i>, end: <i>end</i>)</code> [SAL]<br> |
| 2367 |
<code>(string-upcase <tt><i>str</i></tt> <tt>&key </tt><tt>:start</tt> <tt>:end</tt>)</code> [LISP] – convert to uppercase<br> |
| 2368 |
|
| 2369 |
|
| 2370 |
</div><div style="padding-left: 2em;"> |
| 2371 |
<i>str</i> – the string</div> |
| 2372 |
<div style="padding-left: 2em;"> :start – the starting offset</div> |
| 2373 |
<div style="padding-left: 2em;"> :end – the ending offset + 1</div> |
| 2374 |
<div style="padding-left: 2em;"> returns – a converted copy of the string<br> |
| 2375 |
|
| 2376 |
</div> |
| 2377 |
<br> |
| 2378 |
<code>string-downcase<a name="index1721"></a>(<i>str</i>, start: <i>start</i>, end: <i>end</i>)</code> [SAL]<br> |
| 2379 |
<code>(string-downcase <tt><i>str</i></tt> <tt>&key </tt><tt>:start</tt> <tt>:end</tt>)</code> [LISP] – convert to lowercase<br> |
| 2380 |
|
| 2381 |
|
| 2382 |
</div><div style="padding-left: 2em;"> |
| 2383 |
<i>str</i> – the string</div> |
| 2384 |
<div style="padding-left: 2em;"> :start – the starting offset</div> |
| 2385 |
<div style="padding-left: 2em;"> :end – the ending offset + 1</div> |
| 2386 |
<div style="padding-left: 2em;"> returns – a converted copy of the string<br> |
| 2387 |
|
| 2388 |
</div> |
| 2389 |
<br> |
| 2390 |
<code>nstring-upcase<a name="index1722"></a>(<i>str</i>, start: <i>start</i>, end: <i>end</i>)</code> [SAL]<br> |
| 2391 |
<code>(nstring-upcase <tt><i>str</i></tt> <tt>&key </tt><tt>:start</tt> <tt>:end</tt>)</code> [LISP] – convert to uppercase<br> |
| 2392 |
|
| 2393 |
|
| 2394 |
</div><div style="padding-left: 2em;"> |
| 2395 |
<i>str</i> – the string</div> |
| 2396 |
<div style="padding-left: 2em;"> :start – the starting offset</div> |
| 2397 |
<div style="padding-left: 2em;"> :end – the ending offset + 1</div> |
| 2398 |
<div style="padding-left: 2em;"> returns – the converted string (not a copy)<br> |
| 2399 |
|
| 2400 |
</div> |
| 2401 |
<br> |
| 2402 |
<code>nstring-downcase<a name="index1723"></a>(<i>str</i>, start: <i>start</i>, end: <i>end</i>)</code> [SAL]<br> |
| 2403 |
<code>(nstring-downcase <tt><i>str</i></tt> <tt>&key </tt><tt>:start</tt> <tt>:end</tt>)</code> [LISP] – convert to lowercase<br> |
| 2404 |
|
| 2405 |
|
| 2406 |
</div><div style="padding-left: 2em;"> |
| 2407 |
<i>str</i> – the string</div> |
| 2408 |
<div style="padding-left: 2em;"> :start – the starting offset</div> |
| 2409 |
<div style="padding-left: 2em;"> :end – the ending offset + 1</div> |
| 2410 |
<div style="padding-left: 2em;"> returns – the converted string (not a copy)<br> |
| 2411 |
|
| 2412 |
</div> |
| 2413 |
<br> |
| 2414 |
<code>strcat<a name="index1724"></a>(<i>expr</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2415 |
<code>(strcat<a name="index1725"></a> <tt><i>expr</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – concatenate strings<br> |
| 2416 |
|
| 2417 |
|
| 2418 |
</div><div style="padding-left: 2em;"> |
| 2419 |
<i>expr</i> – the strings to concatenate</div> |
| 2420 |
<div style="padding-left: 2em;"> returns – the result of concatenating the strings<br> |
| 2421 |
|
| 2422 |
</div> |
| 2423 |
<br> |
| 2424 |
<code>subseq<a name="index1726"></a>(<i>string</i>, <i>start</i> [, <i>end</i>])</code> [SAL]<br> |
| 2425 |
<code>(subseq <tt><i>string</i></tt> <tt><i>start</i></tt> [<tt><i>end</i></tt>])</code> [LISP] – extract a substring<br> |
| 2426 |
|
| 2427 |
|
| 2428 |
</div><div style="padding-left: 2em;"> |
| 2429 |
<i>string</i> – the string</div> |
| 2430 |
<div style="padding-left: 2em;"> <i>start</i> – the starting position (zero origin)</div> |
| 2431 |
<div style="padding-left: 2em;"> <i>end</i> – the ending position + 1 (defaults to end)</div> |
| 2432 |
<div style="padding-left: 2em;"> returns – substring between <i>start</i> and <i>end</i><br> |
| 2433 |
|
| 2434 |
</div> |
| 2435 |
<br> |
| 2436 |
<code>string<<a name="index1727"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2437 |
<code>(string< <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2438 |
|
| 2439 |
|
| 2440 |
</div><div style="padding-left: 2em;"> |
| 2441 |
</div> |
| 2442 |
|
| 2443 |
<code>string<=<a name="index1728"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2444 |
<code>(string<= <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2445 |
|
| 2446 |
|
| 2447 |
</div><div style="padding-left: 2em;"> |
| 2448 |
</div> |
| 2449 |
|
| 2450 |
<code>string=<a name="index1729"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2451 |
<code>(string= <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2452 |
|
| 2453 |
|
| 2454 |
</div><div style="padding-left: 2em;"> |
| 2455 |
</div> |
| 2456 |
|
| 2457 |
<code>string/=<a name="index1730"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2458 |
<code>(string/= <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2459 |
|
| 2460 |
|
| 2461 |
</div><div style="padding-left: 2em;"> |
| 2462 |
</div> |
| 2463 |
|
| 2464 |
<code>string>=<a name="index1731"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2465 |
<code>(string>= <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2466 |
|
| 2467 |
|
| 2468 |
</div><div style="padding-left: 2em;"> |
| 2469 |
</div> |
| 2470 |
|
| 2471 |
<code>string><a name="index1732"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2472 |
<code>(string> <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2473 |
|
| 2474 |
|
| 2475 |
</div><div style="padding-left: 2em;"> |
| 2476 |
<i>str1</i> – the first string to compare</div> |
| 2477 |
<div style="padding-left: 2em;"> <i>str2</i> – the second string to compare</div> |
| 2478 |
<div style="padding-left: 2em;"> :start1 – first substring starting offset</div> |
| 2479 |
<div style="padding-left: 2em;"> :end1 – first substring ending offset + 1</div> |
| 2480 |
<div style="padding-left: 2em;"> :start2 – second substring starting offset</div> |
| 2481 |
<div style="padding-left: 2em;"> :end2 – second substring ending offset + 1</div> |
| 2482 |
<div style="padding-left: 2em;"> returns – <code>t</code> if predicate is true, <code>nil</code> otherwise</div> |
| 2483 |
<div style="padding-left: 2em;"> Note: case is significant with these comparison functions.<br> |
| 2484 |
|
| 2485 |
</div> |
| 2486 |
<br> |
| 2487 |
<code>string-lessp<a name="index1733"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2488 |
<code>(string-lessp <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2489 |
|
| 2490 |
|
| 2491 |
</div><div style="padding-left: 2em;"> |
| 2492 |
</div> |
| 2493 |
|
| 2494 |
<code>string-not-greaterp<a name="index1734"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2495 |
<code>(string-not-greaterp <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2496 |
|
| 2497 |
|
| 2498 |
</div><div style="padding-left: 2em;"> |
| 2499 |
</div> |
| 2500 |
|
| 2501 |
<code>string-equal<a name="index1735"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2502 |
<code>(string-equal <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2503 |
|
| 2504 |
|
| 2505 |
</div><div style="padding-left: 2em;"> |
| 2506 |
</div> |
| 2507 |
|
| 2508 |
<code>string-not-equal<a name="index1736"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2509 |
<code>(string-not-equal <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2510 |
|
| 2511 |
|
| 2512 |
</div><div style="padding-left: 2em;"> |
| 2513 |
</div> |
| 2514 |
|
| 2515 |
<code>string-not-lessp<a name="index1737"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2516 |
<code>(string-not-lessp <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2517 |
|
| 2518 |
|
| 2519 |
</div><div style="padding-left: 2em;"> |
| 2520 |
</div> |
| 2521 |
|
| 2522 |
<code>string-greaterp<a name="index1738"></a>(<i>str1</i>, <i>str2</i>, start1: <i>start1</i>, end1: <i>end1</i>, start2: <i>start2</i>, end2: <i>end2</i>)</code> [SAL]<br> |
| 2523 |
<code>(string-greaterp <tt><i>str1</i></tt> <tt><i>str2</i></tt> <tt>&key </tt><tt>:start1</tt> <tt>:end1</tt> <tt>:start2</tt> <tt>:end2</tt>)</code> [LISP]<br> |
| 2524 |
|
| 2525 |
|
| 2526 |
</div><div style="padding-left: 2em;"> |
| 2527 |
<i>str1</i> – the first string to compare</div> |
| 2528 |
<div style="padding-left: 2em;"> <i>str2</i> – the second string to compare</div> |
| 2529 |
<div style="padding-left: 2em;"> :start1 – first substring starting offset</div> |
| 2530 |
<div style="padding-left: 2em;"> :end1 – first substring ending offset + 1</div> |
| 2531 |
<div style="padding-left: 2em;"> :start2 – second substring starting offset</div> |
| 2532 |
<div style="padding-left: 2em;"> :end2 – second substring ending offset + 1</div> |
| 2533 |
<div style="padding-left: 2em;"> returns – <code>t</code> if predicate is true, <code>nil</code> otherwise</div> |
| 2534 |
<div style="padding-left: 2em;"> Note: case is not significant with these comparison functions.<br> |
| 2535 |
|
| 2536 |
</div> |
| 2537 |
|
| 2538 |
</div> |
| 2539 |
<a name = "254"><h3>Character Functions</h3></a><a name="index1739"></a><div style="padding-left: 0em;"> |
| 2540 |
<code>char<a name="index1740"></a><a name="index1741"></a><a name="index1742"></a><a name="index1743"></a><a name="index1744"></a><a name="index1745"></a>(<i>string</i>, <i>index</i>)</code> [SAL]<br> |
| 2541 |
<code>(char <tt><i>string</i></tt> <tt><i>index</i></tt>)</code> [LISP] – extract a character from a string<br> |
| 2542 |
|
| 2543 |
|
| 2544 |
</div><div style="padding-left: 2em;"> |
| 2545 |
<i>string</i> – the string</div> |
| 2546 |
<div style="padding-left: 2em;"> <i>index</i> – the string index (zero relative)</div> |
| 2547 |
<div style="padding-left: 2em;"> returns – the ascii code of the character<br> |
| 2548 |
|
| 2549 |
</div> |
| 2550 |
<br> |
| 2551 |
<code>upper-case-p<a name="index1746"></a>(<i>chr</i>)</code> [SAL]<br> |
| 2552 |
<code>(upper-case-p <tt><i>chr</i></tt>)</code> [LISP] – is this an upper case character?<br> |
| 2553 |
|
| 2554 |
|
| 2555 |
</div><div style="padding-left: 2em;"> |
| 2556 |
<i>chr</i> – the character</div> |
| 2557 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the character is upper case, <code>nil</code> otherwise<br> |
| 2558 |
|
| 2559 |
</div> |
| 2560 |
<br> |
| 2561 |
<code>lower-case-p<a name="index1747"></a>(<i>chr</i>)</code> [SAL]<br> |
| 2562 |
<code>(lower-case-p <tt><i>chr</i></tt>)</code> [LISP] – is this a lower case character?<br> |
| 2563 |
|
| 2564 |
|
| 2565 |
</div><div style="padding-left: 2em;"> |
| 2566 |
<i>chr</i> – the character</div> |
| 2567 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the character is lower case, <code>nil</code> otherwise<br> |
| 2568 |
|
| 2569 |
</div> |
| 2570 |
<br> |
| 2571 |
<code>both-case-p<a name="index1748"></a>(<i>chr</i>)</code> [SAL]<br> |
| 2572 |
<code>(both-case-p <tt><i>chr</i></tt>)</code> [LISP] – is this an alphabetic (either case) character?<br> |
| 2573 |
|
| 2574 |
|
| 2575 |
</div><div style="padding-left: 2em;"> |
| 2576 |
<i>chr</i> – the character</div> |
| 2577 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the character is alphabetic, <code>nil</code> otherwise<br> |
| 2578 |
|
| 2579 |
</div> |
| 2580 |
<br> |
| 2581 |
<code>digit-char-p<a name="index1749"></a>(<i>chr</i>)</code> [SAL]<br> |
| 2582 |
<code>(digit-char-p <tt><i>chr</i></tt>)</code> [LISP] – is this a digit character?<br> |
| 2583 |
|
| 2584 |
|
| 2585 |
</div><div style="padding-left: 2em;"> |
| 2586 |
<i>chr</i> – the character</div> |
| 2587 |
<div style="padding-left: 2em;"> returns – the digit weight if character is a digit, <code>nil</code> otherwise<br> |
| 2588 |
|
| 2589 |
</div> |
| 2590 |
<br> |
| 2591 |
<code>char-code<a name="index1750"></a><a name="index1751"></a><a name="index1752"></a>(<i>chr</i>)</code> [SAL]<br> |
| 2592 |
<code>(char-code <tt><i>chr</i></tt>)</code> [LISP] – get the ascii code of a character<br> |
| 2593 |
|
| 2594 |
|
| 2595 |
</div><div style="padding-left: 2em;"> |
| 2596 |
<i>chr</i> – the character</div> |
| 2597 |
<div style="padding-left: 2em;"> returns – the ascii character code (integer)<br> |
| 2598 |
|
| 2599 |
</div> |
| 2600 |
<br> |
| 2601 |
<code>code-char<a name="index1753"></a><a name="index1754"></a><a name="index1755"></a>(<i>code</i>)</code> [SAL]<br> |
| 2602 |
<code>(code-char <tt><i>code</i></tt>)</code> [LISP] – get the character with a specified ascii code<br> |
| 2603 |
|
| 2604 |
|
| 2605 |
</div><div style="padding-left: 2em;"> |
| 2606 |
<i>code</i> – the ascii code (integer)</div> |
| 2607 |
<div style="padding-left: 2em;"> returns – the character with that code or <code>nil</code><br> |
| 2608 |
|
| 2609 |
</div> |
| 2610 |
<br> |
| 2611 |
<code>char-upcase<a name="index1756"></a>(<i>chr</i>)</code> [SAL]<br> |
| 2612 |
<code>(char-upcase <tt><i>chr</i></tt>)</code> [LISP] – convert a character to upper case<br> |
| 2613 |
|
| 2614 |
|
| 2615 |
</div><div style="padding-left: 2em;"> |
| 2616 |
<i>chr</i> – the character</div> |
| 2617 |
<div style="padding-left: 2em;"> returns – the upper case character<br> |
| 2618 |
|
| 2619 |
</div> |
| 2620 |
<br> |
| 2621 |
<code>char-downcase<a name="index1757"></a>(<i>chr</i>)</code> [SAL]<br> |
| 2622 |
<code>(char-downcase <tt><i>chr</i></tt>)</code> [LISP] – convert a character to lower case<br> |
| 2623 |
|
| 2624 |
|
| 2625 |
</div><div style="padding-left: 2em;"> |
| 2626 |
<i>chr</i> – the character</div> |
| 2627 |
<div style="padding-left: 2em;"> returns – the lower case character<br> |
| 2628 |
|
| 2629 |
</div> |
| 2630 |
<br> |
| 2631 |
<code>digit-char<a name="index1758"></a>(<i>n</i>)</code> [SAL]<br> |
| 2632 |
<code>(digit-char <tt><i>n</i></tt>)</code> [LISP] – convert a digit weight to a digit<br> |
| 2633 |
|
| 2634 |
|
| 2635 |
</div><div style="padding-left: 2em;"> |
| 2636 |
<i>n</i> – the digit weight (integer)</div> |
| 2637 |
<div style="padding-left: 2em;"> returns – the digit character or <code>nil</code><br> |
| 2638 |
|
| 2639 |
</div> |
| 2640 |
<br> |
| 2641 |
<code>char-int<a name="index1759"></a>(<i>chr</i>)</code> [SAL]<br> |
| 2642 |
<code>(char-int <tt><i>chr</i></tt>)</code> [LISP] – convert a character to an integer<br> |
| 2643 |
|
| 2644 |
|
| 2645 |
</div><div style="padding-left: 2em;"> |
| 2646 |
<i>chr</i> – the character</div> |
| 2647 |
<div style="padding-left: 2em;"> returns – the ascii character code<br> |
| 2648 |
|
| 2649 |
</div> |
| 2650 |
<br> |
| 2651 |
<code>int-char<a name="index1760"></a>(<i>int</i>)</code> [SAL]<br> |
| 2652 |
<code>(int-char <tt><i>int</i></tt>)</code> [LISP] – convert an integer to a character<br> |
| 2653 |
|
| 2654 |
|
| 2655 |
</div><div style="padding-left: 2em;"> |
| 2656 |
<i>int</i> – the ascii character code</div> |
| 2657 |
<div style="padding-left: 2em;"> returns – the character with that code<br> |
| 2658 |
|
| 2659 |
</div> |
| 2660 |
<br> |
| 2661 |
<code>char<<a name="index1761"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2662 |
<code>(char< <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2663 |
|
| 2664 |
|
| 2665 |
</div><div style="padding-left: 2em;"> |
| 2666 |
</div> |
| 2667 |
|
| 2668 |
<code>char<=<a name="index1762"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2669 |
<code>(char<= <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2670 |
|
| 2671 |
<code>char=<a name="index1763"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2672 |
<code>(char= <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2673 |
|
| 2674 |
|
| 2675 |
</div><div style="padding-left: 2em;"> |
| 2676 |
</div> |
| 2677 |
|
| 2678 |
<code>char/=<a name="index1764"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2679 |
<code>(char/= <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2680 |
|
| 2681 |
|
| 2682 |
</div><div style="padding-left: 2em;"> |
| 2683 |
</div> |
| 2684 |
|
| 2685 |
<code>char>=<a name="index1765"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2686 |
<code>(char>= <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2687 |
|
| 2688 |
|
| 2689 |
</div><div style="padding-left: 2em;"> |
| 2690 |
</div> |
| 2691 |
|
| 2692 |
<code>char><a name="index1766"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2693 |
<code>(char> <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2694 |
|
| 2695 |
|
| 2696 |
</div><div style="padding-left: 2em;"> |
| 2697 |
<i>chr1</i> – the first character to compare</div> |
| 2698 |
<div style="padding-left: 2em;"> <i>chr2</i> – the second character(s) to compare</div> |
| 2699 |
<div style="padding-left: 2em;"> returns – <code>t</code> if predicate is true, <code>nil</code> otherwise</div> |
| 2700 |
<div style="padding-left: 2em;"> Note: case is significant with these comparison functions.<br> |
| 2701 |
|
| 2702 |
</div> |
| 2703 |
<br> |
| 2704 |
<code>char-lessp<a name="index1767"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2705 |
<code>(char-lessp <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2706 |
|
| 2707 |
|
| 2708 |
</div><div style="padding-left: 2em;"> |
| 2709 |
</div> |
| 2710 |
|
| 2711 |
<code>char-not-greaterp<a name="index1768"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2712 |
<code>(char-not-greaterp <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2713 |
|
| 2714 |
|
| 2715 |
</div><div style="padding-left: 2em;"> |
| 2716 |
</div> |
| 2717 |
|
| 2718 |
<code>char-equal<a name="index1769"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2719 |
<code>(char-equal <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2720 |
|
| 2721 |
|
| 2722 |
</div><div style="padding-left: 2em;"> |
| 2723 |
</div> |
| 2724 |
|
| 2725 |
<code>char-not-equal<a name="index1770"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2726 |
<code>(char-not-equal <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2727 |
|
| 2728 |
|
| 2729 |
</div><div style="padding-left: 2em;"> |
| 2730 |
</div> |
| 2731 |
|
| 2732 |
<code>char-not-lessp<a name="index1771"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2733 |
<code>(char-not-lessp <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2734 |
|
| 2735 |
|
| 2736 |
</div><div style="padding-left: 2em;"> |
| 2737 |
</div> |
| 2738 |
|
| 2739 |
<code>char-greaterp<a name="index1772"></a>(<i>chr1</i>, <i>chr2</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2740 |
<code>(char-greaterp <tt><i>chr1</i></tt> <tt><i>chr2</i></tt><span style="font-style:normal">...</span>)</code> [LISP]<br> |
| 2741 |
|
| 2742 |
|
| 2743 |
</div><div style="padding-left: 2em;"> |
| 2744 |
<i>chr1</i> – the first string to compare</div> |
| 2745 |
<div style="padding-left: 2em;"><i>chr2</i> – the second string(s) to compare</div> |
| 2746 |
<div style="padding-left: 2em;">returns – <code>t</code> if predicate is true, <code>nil</code> otherwise</div> |
| 2747 |
<div style="padding-left: 2em;"> Note: case is not significant with these comparison functions.<br> |
| 2748 |
|
| 2749 |
</div> |
| 2750 |
|
| 2751 |
</div> |
| 2752 |
<a name = "255"><h3>Input/Output Functions</h3></a><a name="index1773"></a><div style="padding-left: 0em;"> |
| 2753 |
<code>read<a name="index1774"></a>([<i>stream</i> [, <i>eof</i> [, <i>rflag</i>]]])</code> [SAL]<br> |
| 2754 |
<code>(read [<tt><i>stream</i></tt> [<tt><i>eof</i></tt> [<tt><i>rflag</i></tt>]]])</code> [LISP] – read an expression<br> |
| 2755 |
|
| 2756 |
|
| 2757 |
</div><div style="padding-left: 2em;"> |
| 2758 |
<i>stream</i> – the input stream (default is standard input)</div> |
| 2759 |
<div style="padding-left: 2em;"> <i>eof</i> – the value to return on end of file (default is <code>nil</code>)</div> |
| 2760 |
<div style="padding-left: 2em;"> <i>rflag</i> – recursive read flag (default is <code>nil</code>)</div> |
| 2761 |
<div style="padding-left: 2em;"> returns – the expression read<br> |
| 2762 |
|
| 2763 |
</div> |
| 2764 |
<br> |
| 2765 |
<code>(print<a name="index1775"></a> <tt><i>expr</i></tt> [<tt><i>stream</i></tt>])</code> [LISP] – print an expression on a new line |
| 2766 |
</div><div style="padding-left: 2em;"> |
| 2767 |
<i>expr</i> – the expression to be printed</div> |
| 2768 |
<div style="padding-left: 2em;"> <i>stream</i> – the output stream (default is standard output)</div> |
| 2769 |
<div style="padding-left: 2em;"> returns – the expression<br> |
| 2770 |
|
| 2771 |
</div> |
| 2772 |
<br> |
| 2773 |
<code>(display<a name="index1776"></a><a name="index1777"></a> |
| 2774 |
<tt><i>label</i></tt> <tt><i>expr</i><span style="font-style:normal">...</span></tt>)</code> [LISP] |
| 2775 |
– print expressions and their values |
| 2776 |
</div><div style="padding-left: 2em;"> |
| 2777 |
<i>label</i> – a string prefix to print, often the current function name or something to identify the source of this line of output</div> |
| 2778 |
<div style="padding-left: 2em;"> <i>expr</i> – a list of expressions. Each expression is printed literally without evaluation, then it is evaluated and the value is printed. This helps to generate readable debugging output such as "In foo: A = 4, B = 2.5"</div> |
| 2779 |
<div style="padding-left: 2em;"> returns – the expression</div> |
| 2780 |
<div style="padding-left: 2em;"> Note: Output from <tt>display</tt> can be turned on and off by calling <tt>display-on</tt> or <tt>display-off</tt> as described below. This is not part of standard XLISP nor is it built-in. Nyquist defines it though.</div> |
| 2781 |
<div style="padding-left: 2em;"></div><br> |
| 2782 |
<code>(display-on<a name="index1778"></a>)</code> [LISP] |
| 2783 |
– enable <tt>display</tt> macro |
| 2784 |
</div><div style="padding-left: 2em;"> |
| 2785 |
returns – T</div> |
| 2786 |
<div style="padding-left: 2em;"> Note: This call gives <tt>display</tt> its default definition as described above. This is not part of standard XLISP nor is it built-in. Nyquist defines it though.</div> |
| 2787 |
<div style="padding-left: 2em;"></div><br> |
| 2788 |
<code>(display-off<a name="index1779"></a>)</code> [LISP] |
| 2789 |
– disable <tt>display</tt> macro |
| 2790 |
</div><div style="padding-left: 2em;"> |
| 2791 |
returns – NIL</div> |
| 2792 |
<div style="padding-left: 2em;"> Note: This call redefines <tt>display</tt> to just evaluate arguments and not print anything.</div> |
| 2793 |
<div style="padding-left: 2em;"> This is not part of standard XLISP nor is it built-in. Nyquist defines it though.</div> |
| 2794 |
<div style="padding-left: 2em;"></div><br> |
| 2795 |
<code>prin1<a name="index1780"></a>(<i>expr</i> [, <i>stream</i>])</code> [SAL]<br> |
| 2796 |
<code>(prin1 <tt><i>expr</i></tt> [<tt><i>stream</i></tt>])</code> [LISP] – print an expression<br> |
| 2797 |
|
| 2798 |
|
| 2799 |
</div><div style="padding-left: 2em;"> |
| 2800 |
<i>expr</i> – the expression to be printed</div> |
| 2801 |
<div style="padding-left: 2em;"> <i>stream</i> – the output stream (default is standard output)</div> |
| 2802 |
<div style="padding-left: 2em;"> returns – the expression<br> |
| 2803 |
|
| 2804 |
</div> |
| 2805 |
<br> |
| 2806 |
<code>princ<a name="index1781"></a>(<i>expr</i> [, <i>stream</i>])</code> [SAL]<br> |
| 2807 |
<code>(princ <tt><i>expr</i></tt> [<tt><i>stream</i></tt>])</code> [LISP] – print an expression without quoting<br> |
| 2808 |
|
| 2809 |
|
| 2810 |
</div><div style="padding-left: 2em;"> |
| 2811 |
<i>expr</i> – the expressions to be printed</div> |
| 2812 |
<div style="padding-left: 2em;"> <i>stream</i> – the output stream (default is standard output)</div> |
| 2813 |
<div style="padding-left: 2em;"> returns – the expression<br> |
| 2814 |
|
| 2815 |
</div> |
| 2816 |
<br> |
| 2817 |
<code>pprint<a name="index1782"></a>(<i>expr</i> [, <i>stream</i>])</code> [SAL]<br> |
| 2818 |
<code>(pprint <tt><i>expr</i></tt> [<tt><i>stream</i></tt>])</code> [LISP] – pretty print an expression<br> |
| 2819 |
|
| 2820 |
|
| 2821 |
</div><div style="padding-left: 2em;"> |
| 2822 |
<i>expr</i> – the expressions to be printed</div> |
| 2823 |
<div style="padding-left: 2em;"> <i>stream</i> – the output stream (default is standard output)</div> |
| 2824 |
<div style="padding-left: 2em;"> returns – the expression<br> |
| 2825 |
|
| 2826 |
</div> |
| 2827 |
<br> |
| 2828 |
<code>terpri<a name="index1783"></a>([<i>stream</i>])</code> [SAL]<br> |
| 2829 |
<code>(terpri [<tt><i>stream</i></tt>])</code> [LISP] – terminate the current print line<br> |
| 2830 |
|
| 2831 |
|
| 2832 |
</div><div style="padding-left: 2em;"> |
| 2833 |
<i>stream</i> – the output stream (default is standard output)</div> |
| 2834 |
<div style="padding-left: 2em;"> returns – <code>nil</code><br> |
| 2835 |
|
| 2836 |
</div> |
| 2837 |
<br> |
| 2838 |
<code>flatsize<a name="index1784"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2839 |
<code>(flatsize <tt><i>expr</i></tt>)</code> [LISP] – length of printed representation using prin1<br> |
| 2840 |
|
| 2841 |
|
| 2842 |
</div><div style="padding-left: 2em;"> |
| 2843 |
<i>expr</i> – the expression</div> |
| 2844 |
<div style="padding-left: 2em;"> returns – the length<br> |
| 2845 |
|
| 2846 |
</div> |
| 2847 |
<br> |
| 2848 |
<code>flatc<a name="index1785"></a>(<i>expr</i>)</code> [SAL]<br> |
| 2849 |
<code>(flatc <tt><i>expr</i></tt>)</code> [LISP] – length of printed representation using princ<br> |
| 2850 |
|
| 2851 |
|
| 2852 |
</div><div style="padding-left: 2em;"> |
| 2853 |
<i>expr</i> – the expression</div> |
| 2854 |
<div style="padding-left: 2em;"> returns – the length<br> |
| 2855 |
|
| 2856 |
</div> |
| 2857 |
|
| 2858 |
</div> |
| 2859 |
<a name = "256"><h3>The Format Function</h3></a><a name="index1786"></a><a name="index1787"></a><div style="padding-left: 0em;"> |
| 2860 |
<code>format<a name="index1788"></a>(<i>stream</i>, <i>fmt</i>, <i>arg</i><span style="font-style:normal">...</span>)</code> [SAL]<br> |
| 2861 |
<code>(format <tt><i>stream</i></tt> <tt><i>fmt</i></tt> <tt><i>arg</i></tt><span style="font-style:normal">...</span>)</code> [LISP] – do formated<br> |
| 2862 |
|
| 2863 |
|
| 2864 |
output |
| 2865 |
</div><div style="padding-left: 2em;"> |
| 2866 |
<i>stream</i> – the output stream</div> |
| 2867 |
<div style="padding-left: 2em;"> <i>fmt</i> – the format string</div> |
| 2868 |
<div style="padding-left: 2em;"> <i>arg</i> – the format arguments</div> |
| 2869 |
<div style="padding-left: 2em;"> returns – output string if <i>stream</i> is <code>nil</code>, <code>nil</code> otherwise<br> |
| 2870 |
|
| 2871 |
</div> |
| 2872 |
|
| 2873 |
</div> |
| 2874 |
|
| 2875 |
The format string can contain characters that should be copied |
| 2876 |
directly to the output and formatting directives. The |
| 2877 |
formatting directives are: |
| 2878 |
<blockquote> |
| 2879 |
<code>~A</code> – print next argument using princ<br> |
| 2880 |
|
| 2881 |
<code>~S</code> – print next argument using prin1<br> |
| 2882 |
|
| 2883 |
<code>~%</code> – start a new line<br> |
| 2884 |
|
| 2885 |
<code>~~</code> – print a tilde character<br> |
| 2886 |
|
| 2887 |
<code>~</code><newline> – ignore this one newline and white space on the <br> |
| 2888 |
|
| 2889 |
next line up to the first non-white-space character or newline. This <br> |
| 2890 |
|
| 2891 |
allows strings to continue across multiple lines<br> |
| 2892 |
|
| 2893 |
</blockquote><a name = "257"><h3>File I/O Functions</h3></a><a name="index1789"></a> |
| 2894 |
<p>Note that files are ordinarily opened as text. Binary files (such as standard midi files) must be opened with <code>open-binary</code> on non-unix systems. |
| 2895 |
|
| 2896 |
|
| 2897 |
<div style="padding-left: 0em;"> |
| 2898 |
<code>open<a name="index1790"></a>(<i>fname</i>, direction: <i>direction</i>)</code> [SAL]<br> |
| 2899 |
<code>(open <tt><i>fname</i></tt> <tt>&key </tt><tt>:direction</tt>)</code> [LISP] – open a file stream<br> |
| 2900 |
|
| 2901 |
|
| 2902 |
</div><div style="padding-left: 2em;"> |
| 2903 |
<i>fname</i> – the file name string or symbol</div> |
| 2904 |
<div style="padding-left: 2em;"> :direction – :input or :output (default is :input)</div> |
| 2905 |
<div style="padding-left: 2em;"> returns – a stream<br> |
| 2906 |
|
| 2907 |
</div> |
| 2908 |
<br> |
| 2909 |
<code>open-binary<a name="index1791"></a>(<i>fname</i>, direction: <i>direction</i>)</code> [SAL]<br> |
| 2910 |
<code>(open-binary<a name="index1792"></a><a name="index1793"></a> <tt><i>fname</i></tt> <tt>&key </tt><tt>:direction</tt>)</code> [LISP] – open a binary file stream<br> |
| 2911 |
|
| 2912 |
|
| 2913 |
</div><div style="padding-left: 2em;"> |
| 2914 |
<i>fname</i> – the file name string or symbol</div> |
| 2915 |
<div style="padding-left: 2em;"> :direction – :input or :output (default is :input)</div> |
| 2916 |
<div style="padding-left: 2em;"> returns – a stream<br> |
| 2917 |
|
| 2918 |
</div> |
| 2919 |
<br> |
| 2920 |
<code>close<a name="index1794"></a>(<i>stream</i>)</code> [SAL]<br> |
| 2921 |
<code>(close <tt><i>stream</i></tt>)</code> [LISP] – close a file stream<br> |
| 2922 |
|
| 2923 |
|
| 2924 |
</div><div style="padding-left: 2em;"> |
| 2925 |
<i>stream</i> – the stream</div> |
| 2926 |
<div style="padding-left: 2em;"> returns – <code>nil</code><br> |
| 2927 |
|
| 2928 |
</div> |
| 2929 |
<br> |
| 2930 |
<code>setdir<a name="index1795"></a>(<i>path</i> [, <i>verbose</i>])</code> [SAL]<br> |
| 2931 |
<code>(setdir<a name="index1796"></a> <tt><i>path</i></tt> [<tt><i>verbose</i></tt>])</code> [LISP] – set current directory<br> |
| 2932 |
|
| 2933 |
|
| 2934 |
</div><div style="padding-left: 2em;"> |
| 2935 |
<i>path</i> – the path of the new directory</div> |
| 2936 |
<div style="padding-left: 2em;"> <i>verbose</i> – print error message if current directory cannot be changed to <i>path</i></div> |
| 2937 |
<div style="padding-left: 2em;"> returns – the resulting full path, e.g. (setdir ".") gets the current working directory, or <code>nil</code> if an error occurs</div> |
| 2938 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 2939 |
|
| 2940 |
</div> |
| 2941 |
<br> |
| 2942 |
<code>listdir<a name="index1797"></a>(<i>path</i>)</code> [SAL]<br> |
| 2943 |
<code>(listdir<a name="index1798"></a><a name="index1799"></a><a name="index1800"></a><a name="index1801"></a> <tt><i>path</i></tt>)</code> [LISP] – get a directory listing<br> |
| 2944 |
|
| 2945 |
|
| 2946 |
</div><div style="padding-left: 2em;"> |
| 2947 |
<i>path</i> – the path of the directory to be listed</div> |
| 2948 |
<div style="padding-left: 2em;"> returns – list of filenames in the directory</div> |
| 2949 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 2950 |
|
| 2951 |
</div> |
| 2952 |
<br> |
| 2953 |
<code>get-temp-path<a name="index1802"></a>()</code> [SAL]<br> |
| 2954 |
<code>(get-temp-path<a name="index1803"></a><a name="index1804"></a>)</code> [LISP] – get a path where a temporary file can be created. Under Windows, this is based on environment variables. If XLISP is running as a sub-process to Java, the environment may not exist, in which case the default result is the unfortunate choice <code>c:\windows\</code>.<br> |
| 2955 |
|
| 2956 |
|
| 2957 |
</div><div style="padding-left: 2em;"> |
| 2958 |
returns – the resulting full path as a string</div> |
| 2959 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 2960 |
|
| 2961 |
</div> |
| 2962 |
<br> |
| 2963 |
<code>get-user<a name="index1805"></a>()</code> [SAL]<br> |
| 2964 |
<code>(get-user<a name="index1806"></a><a name="index1807"></a>)</code> [LISP] – get the user ID. In Unix systems (including OS X and Linux), this is the value of the USER environment variable. In Windows, this is currently just “nyquist”, which is also returned if the environment variable cannot be accessed. This function is used to avoid the case of two users creating files of the same name in the same temp directory.<br> |
| 2965 |
|
| 2966 |
|
| 2967 |
</div><div style="padding-left: 2em;"> |
| 2968 |
returns – the string naming the user</div> |
| 2969 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 2970 |
|
| 2971 |
</div> |
| 2972 |
<br> |
| 2973 |
<code>find-in-xlisp-path<a name="index1808"></a>(<i>filename</i>)</code> [SAL]<br> |
| 2974 |
<code>(find-in-xlisp-path <tt><i>filename</i></tt>)</code> [LISP] – search the XLISP search path (e.g. <code>XLISPPATH</code> from the environment) for <i>filename</i>. If <i>filename</i> is not found as is, and there is no file extension, append "<code>.lsp</code>" to <i>filename</i> and search again. The current directory is not searched.<br> |
| 2975 |
|
| 2976 |
|
| 2977 |
</div><div style="padding-left: 2em;"> |
| 2978 |
<i>filename</i> – the name of the file to search for</div> |
| 2979 |
<div style="padding-left: 2em;"> returns – a full path name to the first occurrence found</div> |
| 2980 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 2981 |
|
| 2982 |
</div> |
| 2983 |
<br> |
| 2984 |
<code>read-char<a name="index1809"></a>([<i>stream</i>])</code> [SAL]<br> |
| 2985 |
<code>(read-char<a name="index1810"></a> [<tt><i>stream</i></tt>])</code> [LISP] – read a character from a stream<br> |
| 2986 |
|
| 2987 |
|
| 2988 |
</div><div style="padding-left: 2em;"> |
| 2989 |
<i>stream</i> – the input stream (default is standard input)</div> |
| 2990 |
<div style="padding-left: 2em;"> returns – the character<br> |
| 2991 |
|
| 2992 |
</div> |
| 2993 |
<br> |
| 2994 |
<code>peek-char<a name="index1811"></a>([<i>flag</i> [, <i>stream</i>]])</code> [SAL]<br> |
| 2995 |
<code>(peek-char [<tt><i>flag</i></tt> [<tt><i>stream</i></tt>]])</code> [LISP] – peek at the next character<br> |
| 2996 |
|
| 2997 |
|
| 2998 |
</div><div style="padding-left: 2em;"> |
| 2999 |
<i>flag</i> – flag for skipping white space (default is <code>nil</code>)</div> |
| 3000 |
<div style="padding-left: 2em;"> <i>stream</i> – the input stream (default is standard input)</div> |
| 3001 |
<div style="padding-left: 2em;"> returns – the character<br> |
| 3002 |
|
| 3003 |
</div> |
| 3004 |
<br> |
| 3005 |
<code>write-char<a name="index1812"></a>(<i>ch</i> [, <i>stream</i>])</code> [SAL]<br> |
| 3006 |
<code>(write-char <tt><i>ch</i></tt> [<tt><i>stream</i></tt>])</code> [LISP] – write a character to a stream<br> |
| 3007 |
|
| 3008 |
|
| 3009 |
</div><div style="padding-left: 2em;"> |
| 3010 |
<i>ch</i> – the character to write</div> |
| 3011 |
<div style="padding-left: 2em;"> <i>stream</i> – the output stream (default is standard output)</div> |
| 3012 |
<div style="padding-left: 2em;"> returns – the character<br> |
| 3013 |
|
| 3014 |
</div> |
| 3015 |
<br> |
| 3016 |
<code>read-int<a name="index1813"></a>([<i>stream</i> [, <i>length</i>]])</code> [SAL]<br> |
| 3017 |
<code>(read-int [<tt><i>stream</i></tt> [<tt><i>length</i></tt>]])</code> [LISP] – read a binary integer from a stream<br> |
| 3018 |
|
| 3019 |
|
| 3020 |
</div><div style="padding-left: 2em;"> |
| 3021 |
<i>stream</i> – the input stream (default is standard input)</div> |
| 3022 |
<div style="padding-left: 2em;"> <i>length</i> – the length of the integer in bytes (default is 4)</div> |
| 3023 |
<div style="padding-left: 2em;"> returns – the integer</div> |
| 3024 |
<div style="padding-left: 2em;">Note: Integers are assumed to be big-endian (high-order byte first) and <br> |
| 3025 |
|
| 3026 |
signed, regardless of the platform. To read little-endian format, use a<br> |
| 3027 |
|
| 3028 |
negative number for the length, e.g. -4 indicates a 4-bytes, low-order<br> |
| 3029 |
|
| 3030 |
byte first. The file should be opened in binary mode.<br> |
| 3031 |
|
| 3032 |
</div> |
| 3033 |
<br> |
| 3034 |
<code>write-int<a name="index1814"></a>(<i>ch</i> [, <i>stream</i> [, <i>length</i>]])</code> [SAL]<br> |
| 3035 |
<code>(write-int <tt><i>ch</i></tt> [<tt><i>stream</i></tt> [<tt><i>length</i></tt>]])</code> [LISP] – write a binary integer to a stream<br> |
| 3036 |
|
| 3037 |
|
| 3038 |
</div><div style="padding-left: 2em;"> |
| 3039 |
<i>ch</i> – the character to write</div> |
| 3040 |
<div style="padding-left: 2em;"> <i>stream</i> – the output stream (default is standard output)</div> |
| 3041 |
<div style="padding-left: 2em;"> <i>length</i> – the length of the integer in bytes (default is 4)</div> |
| 3042 |
<div style="padding-left: 2em;"> returns – the integer</div> |
| 3043 |
<div style="padding-left: 2em;">Note: Integers are assumed to be big-endian (high-order byte first) and <br> |
| 3044 |
|
| 3045 |
signed, regardless of the platform. To write in little-endian format, use a<br> |
| 3046 |
|
| 3047 |
negative number for the length, e.g. -4 indicates a 4-bytes, low-order<br> |
| 3048 |
|
| 3049 |
byte first. The file should be opened in binary mode.<br> |
| 3050 |
|
| 3051 |
</div> |
| 3052 |
<br> |
| 3053 |
<code>read-float<a name="index1815"></a>([<i>stream</i> [, <i>length</i>]])</code> [SAL]<br> |
| 3054 |
<code>(read-float [<tt><i>stream</i></tt> [<tt><i>length</i></tt>]])</code> [LISP] – read a binary floating-point number from a stream<br> |
| 3055 |
|
| 3056 |
|
| 3057 |
</div><div style="padding-left: 2em;"> |
| 3058 |
<i>stream</i> – the input stream (default is standard input)</div> |
| 3059 |
<div style="padding-left: 2em;"> <i>length</i> – the length of the float in bytes (default is 4, legal values are -4, -8, 4, and 8)</div> |
| 3060 |
<div style="padding-left: 2em;"> returns – the integer</div> |
| 3061 |
<div style="padding-left: 2em;">Note: Floats are assumed to be big-endian (high-order byte first) and <br> |
| 3062 |
|
| 3063 |
signed, regardless of the platform. To read little-endian format, use a<br> |
| 3064 |
|
| 3065 |
negative number for the length, e.g. -4 indicates a 4-bytes, low-order<br> |
| 3066 |
|
| 3067 |
byte first. The file should be opened in binary mode.<br> |
| 3068 |
|
| 3069 |
</div> |
| 3070 |
<br> |
| 3071 |
<code>write-float<a name="index1816"></a>(<i>ch</i> [, <i>stream</i> [, <i>length</i>]])</code> [SAL]<br> |
| 3072 |
<code>(write-float <tt><i>ch</i></tt> [<tt><i>stream</i></tt> [<tt><i>length</i></tt>]])</code> [LISP] – write a binary floating-point number to a stream<br> |
| 3073 |
|
| 3074 |
|
| 3075 |
</div><div style="padding-left: 2em;"> |
| 3076 |
<i>ch</i> – the character to write</div> |
| 3077 |
<div style="padding-left: 2em;"> <i>stream</i> – the output stream (default is standard output)</div> |
| 3078 |
<div style="padding-left: 2em;"> <i>length</i> – the length of the float in bytes (default is 4, legal values are -4, -8, 4, and 8)</div> |
| 3079 |
<div style="padding-left: 2em;"> returns – the integer</div> |
| 3080 |
<div style="padding-left: 2em;">Note: Floats are assumed to be big-endian (high-order byte first) and <br> |
| 3081 |
|
| 3082 |
signed, regardless of the platform. To write in little-endian format, use a<br> |
| 3083 |
|
| 3084 |
negative number for the length, e.g. -4 indicates a 4-bytes, low-order<br> |
| 3085 |
|
| 3086 |
byte first. The file should be opened in binary mode.<br> |
| 3087 |
|
| 3088 |
</div> |
| 3089 |
<br> |
| 3090 |
<code>read-line<a name="index1817"></a>([<i>stream</i>])</code> [SAL]<br> |
| 3091 |
<code>(read-line [<tt><i>stream</i></tt>])</code> [LISP] – read a line from a stream<br> |
| 3092 |
|
| 3093 |
|
| 3094 |
</div><div style="padding-left: 2em;"> |
| 3095 |
<i>stream</i> – the input stream (default is standard input)</div> |
| 3096 |
<div style="padding-left: 2em;"> returns – the string<br> |
| 3097 |
|
| 3098 |
</div> |
| 3099 |
<br> |
| 3100 |
<code>read-byte<a name="index1818"></a>([<i>stream</i>])</code> [SAL]<br> |
| 3101 |
<code>(read-byte [<tt><i>stream</i></tt>])</code> [LISP] – read a byte from a stream<br> |
| 3102 |
|
| 3103 |
|
| 3104 |
</div><div style="padding-left: 2em;"> |
| 3105 |
<i>stream</i> – the input stream (default is standard input)</div> |
| 3106 |
<div style="padding-left: 2em;"> returns – the byte (integer)<br> |
| 3107 |
|
| 3108 |
</div> |
| 3109 |
<br> |
| 3110 |
<code>write-byte<a name="index1819"></a>(<i>byte</i> [, <i>stream</i>])</code> [SAL]<br> |
| 3111 |
<code>(write-byte <tt><i>byte</i></tt> [<tt><i>stream</i></tt>])</code> [LISP] – write a byte to a stream<br> |
| 3112 |
|
| 3113 |
|
| 3114 |
</div><div style="padding-left: 2em;"> |
| 3115 |
<i>byte</i> – the byte to write (integer)</div> |
| 3116 |
<div style="padding-left: 2em;"> <i>stream</i> – the output stream (default is standard output)</div> |
| 3117 |
<div style="padding-left: 2em;"> returns – the byte (integer)<br> |
| 3118 |
|
| 3119 |
</div> |
| 3120 |
|
| 3121 |
</div> |
| 3122 |
</p> |
| 3123 |
<a name = "258"><h3>String Stream Functions</h3></a><a name="index1820"></a> |
| 3124 |
<p> These functions operate on unnamed streams. An unnamed output |
| 3125 |
stream collects characters sent to it when it is used as the |
| 3126 |
destination of any output function. The functions |
| 3127 |
<code>get-output-stream-string</code> and <code>get-output-stream-list</code> return a string or a list of characters.</p> |
| 3128 |
|
| 3129 |
<p>An unnamed input stream is setup with the |
| 3130 |
<code>make-string-input-stream</code> function and returns each character of the string when |
| 3131 |
it is used as the source of any input function.</p> |
| 3132 |
<div style="padding-left: 0em;"> |
| 3133 |
<code>make-string-input-stream<a name="index1821"></a>(<i>str</i> [, <i>start</i> [, <i>end</i>]])</code> [SAL]<br> |
| 3134 |
<code>(make-string-input-stream <tt><i>str</i></tt> [<tt><i>start</i></tt> [<tt><i>end</i></tt>]])</code> [LISP]<br> |
| 3135 |
|
| 3136 |
|
| 3137 |
</div><div style="padding-left: 2em;"> |
| 3138 |
<i>str</i> – the string</div> |
| 3139 |
<div style="padding-left: 2em;"> <i>start</i> – the starting offset</div> |
| 3140 |
<div style="padding-left: 2em;"> <i>end</i> – the ending offset + 1</div> |
| 3141 |
<div style="padding-left: 2em;"> returns – an unnamed stream that reads from the string<br> |
| 3142 |
|
| 3143 |
</div> |
| 3144 |
<br> |
| 3145 |
<code>make-string-output-stream<a name="index1822"></a>(<i>stream</i>)</code> [SAL]<br> |
| 3146 |
<code>(make-string-output-stream)</code> [LISP]<br> |
| 3147 |
|
| 3148 |
|
| 3149 |
</div><div style="padding-left: 2em;"> |
| 3150 |
returns – an unnamed output stream<br> |
| 3151 |
|
| 3152 |
</div> |
| 3153 |
<br> |
| 3154 |
<code>get-output-stream-string<a name="index1823"></a>(<i>stream</i>)</code> [SAL]<br> |
| 3155 |
<code>(get-output-stream-string <tt><i>stream</i></tt>)</code> [LISP]<br> |
| 3156 |
|
| 3157 |
|
| 3158 |
</div><div style="padding-left: 2em;"> |
| 3159 |
<i>stream</i> – the output stream</div> |
| 3160 |
<div style="padding-left: 2em;"> returns – the output so far as a string</div> |
| 3161 |
<div style="padding-left: 2em;"> Note: the output stream is emptied by this function<br> |
| 3162 |
|
| 3163 |
</div> |
| 3164 |
<br> |
| 3165 |
<code>get-output-stream-list<a name="index1824"></a>(<i>stream</i>)</code> [SAL]<br> |
| 3166 |
<code>(get-output-stream-list <tt><i>stream</i></tt>)</code> [LISP]<br> |
| 3167 |
|
| 3168 |
|
| 3169 |
</div><div style="padding-left: 2em;"> |
| 3170 |
<i>stream</i> – the output stream</div> |
| 3171 |
<div style="padding-left: 2em;"> returns – the output so far as a list</div> |
| 3172 |
<div style="padding-left: 2em;"> Note: the output stream is emptied by this function<br> |
| 3173 |
|
| 3174 |
</div> |
| 3175 |
|
| 3176 |
</div> |
| 3177 |
<a name = "259"><h3>System Functions</h3></a><a name="index1825"></a> |
| 3178 |
<p>Note: the <code>load</code> function first tries to load a file from the current directory. A <code>.lsp</code> extension is added if there is not already an alphanumeric extension following a period. If that fails, XLISP searches the path, which is obtained from the XLISPPATH environment variable in Unix and HKEY_LOCAL_MACHINE\SOFTWARE\CMU\Nyquist\XLISPPATH under Win32. (The Macintosh version has no search path.) |
| 3179 |
|
| 3180 |
|
| 3181 |
<div style="padding-left: 0em;"> |
| 3182 |
<code>get-real-time<a name="index1826"></a><a name="index1827"></a><a name="index1828"></a><a name="index1829"></a>()</code> [SAL]<br> |
| 3183 |
<code>(get-real-time)</code> [LISP] – get the time<br> |
| 3184 |
|
| 3185 |
|
| 3186 |
</div><div style="padding-left: 2em;"> |
| 3187 |
returns – Time as FLONUM seconds since Jan 1, 1970</div> |
| 3188 |
<div style="padding-left: 2em;">Note: Since the time is a large number, you may want to subtract an earlier time to measure a time interval or use a custom format to print enough precision. (See <code>*float-format*</code> in Section <a href = "#239">Symbols</a>.)<br> |
| 3189 |
|
| 3190 |
</div> |
| 3191 |
<br> |
| 3192 |
<code>get-run-time<a name="index1830"></a><a name="index1831"></a><a name="index1832"></a><a name="index1833"></a>()</code> [SAL]<br> |
| 3193 |
<code>(get-run-time)</code> [LISP] – get the run time based on number of Lisp expression evaluations. Typically, a computer will use one unit of run time in about 10ms, but this can vary either way and depends on CPU speed.<br> |
| 3194 |
|
| 3195 |
|
| 3196 |
</div><div style="padding-left: 2em;"> |
| 3197 |
returns – Time as a FIXNUM.<br> |
| 3198 |
|
| 3199 |
</div> |
| 3200 |
<br> |
| 3201 |
<code>get-env<a name="index1834"></a>(<i>name</i>)</code> [SAL]<br> |
| 3202 |
<code>(get-env<a name="index1835"></a><a name="index1836"></a> <tt><i>name</i></tt>)</code> [LISP] – get from an environment variable<br> |
| 3203 |
|
| 3204 |
|
| 3205 |
</div><div style="padding-left: 2em;"> |
| 3206 |
<i>name</i> – the name of the environment variable</div> |
| 3207 |
<div style="padding-left: 2em;"> returns – string value of the environment variable, <code>nil</code> if variable does not exist<br> |
| 3208 |
|
| 3209 |
</div> |
| 3210 |
<br> |
| 3211 |
<code>(load<a name="index1837"></a> <tt><i>fname</i></tt> <tt>&key </tt><tt>:verbose</tt> <tt>:print</tt>)</code> [LISP] – load a source file |
| 3212 |
</div><div style="padding-left: 2em;"> |
| 3213 |
<i>fname</i> – the filename string or symbol</div> |
| 3214 |
<div style="padding-left: 2em;"> :verbose – the verbose flag (default is t)</div> |
| 3215 |
<div style="padding-left: 2em;"> :print – the print flag (default is <code>nil</code>)</div> |
| 3216 |
<div style="padding-left: 2em;"> returns – the filename<br> |
| 3217 |
|
| 3218 |
</div> |
| 3219 |
<br> |
| 3220 |
<code>save<a name="index1838"></a>(<i>fname</i>)</code> [SAL]<br> |
| 3221 |
<code>(save <tt><i>fname</i></tt>)</code> [LISP] – save workspace to a file<br> |
| 3222 |
|
| 3223 |
|
| 3224 |
</div><div style="padding-left: 2em;"> |
| 3225 |
<i>fname</i> – the filename string or symbol</div> |
| 3226 |
<div style="padding-left: 2em;"> returns – <code>t</code> if workspace was written, <code>nil</code> otherwise<br> |
| 3227 |
|
| 3228 |
</div> |
| 3229 |
<br> |
| 3230 |
<code>restore<a name="index1839"></a>(<i>fname</i>)</code> [SAL]<br> |
| 3231 |
<code>(restore <tt><i>fname</i></tt>)</code> [LISP] – restore workspace from a file<br> |
| 3232 |
|
| 3233 |
|
| 3234 |
</div><div style="padding-left: 2em;"> |
| 3235 |
<i>fname</i> – the filename string or symbol</div> |
| 3236 |
<div style="padding-left: 2em;"> returns – <code>nil</code> on failure, otherwise never returns<br> |
| 3237 |
|
| 3238 |
</div> |
| 3239 |
<br> |
| 3240 |
<code>dribble<a name="index1840"></a>([<i>fname</i>])</code> [SAL]<br> |
| 3241 |
<code>(dribble [<tt><i>fname</i></tt>])</code> [LISP] – create a file with a transcript of a session<br> |
| 3242 |
|
| 3243 |
|
| 3244 |
</div><div style="padding-left: 2em;"> |
| 3245 |
<i>fname</i> – file name string or symbol<br> |
| 3246 |
|
| 3247 |
(if missing, close current transcript)</div> |
| 3248 |
<div style="padding-left: 2em;"> returns – <code>t</code> if the transcript is opened, <code>nil</code> if it is closed<br> |
| 3249 |
|
| 3250 |
</div> |
| 3251 |
<br> |
| 3252 |
<code>gc<a name="index1841"></a><a name="index1842"></a>()</code> [SAL]<br> |
| 3253 |
<code>(gc)</code> [LISP] – force garbage collection<br> |
| 3254 |
|
| 3255 |
|
| 3256 |
</div><div style="padding-left: 2em;"> |
| 3257 |
returns – <code>nil</code><br> |
| 3258 |
|
| 3259 |
</div> |
| 3260 |
<br> |
| 3261 |
<code>expand<a name="index1843"></a>(<i>num</i>)</code> [SAL]<br> |
| 3262 |
<code>(expand <tt><i>num</i></tt>)</code> [LISP] – expand memory by adding segments<br> |
| 3263 |
|
| 3264 |
|
| 3265 |
</div><div style="padding-left: 2em;"> |
| 3266 |
<i>num</i> – the number of segments to add</div> |
| 3267 |
<div style="padding-left: 2em;"> returns – the number of segments added<br> |
| 3268 |
|
| 3269 |
</div> |
| 3270 |
<br> |
| 3271 |
<code>alloc<a name="index1844"></a>(<i>num</i>)</code> [SAL]<br> |
| 3272 |
<code>(alloc <tt><i>num</i></tt>)</code> [LISP] – change number of nodes to allocate in each segment<br> |
| 3273 |
|
| 3274 |
|
| 3275 |
</div><div style="padding-left: 2em;"> |
| 3276 |
<i>num</i> – the number of nodes to allocate</div> |
| 3277 |
<div style="padding-left: 2em;"> returns – the old number of nodes to allocate<br> |
| 3278 |
|
| 3279 |
</div> |
| 3280 |
<br> |
| 3281 |
<code>info<a name="index1845"></a>()</code> [SAL]<br> |
| 3282 |
<code>(info)</code> [LISP] – show information about memory usage.<br> |
| 3283 |
|
| 3284 |
|
| 3285 |
</div><div style="padding-left: 2em;"> |
| 3286 |
returns – <code>nil</code><br> |
| 3287 |
|
| 3288 |
</div> |
| 3289 |
<br> |
| 3290 |
<code>room<a name="index1846"></a>()</code> [SAL]<br> |
| 3291 |
<code>(room)</code> [LISP] – show memory allocation statistics<br> |
| 3292 |
|
| 3293 |
|
| 3294 |
</div><div style="padding-left: 2em;"> |
| 3295 |
returns – <code>nil</code><br> |
| 3296 |
|
| 3297 |
</div> |
| 3298 |
<br> |
| 3299 |
<code>type-of<a name="index1847"></a>(<i>expr</i>)</code> [SAL]<br> |
| 3300 |
<code>(type-of <tt><i>expr</i></tt>)</code> [LISP] – returns the type of the expression<br> |
| 3301 |
|
| 3302 |
|
| 3303 |
</div><div style="padding-left: 2em;"> |
| 3304 |
<i>expr</i> – the expression to return the type of</div> |
| 3305 |
<div style="padding-left: 2em;"> returns – <code>nil</code> if the value is <code>nil</code> otherwise one of the symbols:<br> |
| 3306 |
|
| 3307 |
</div><div style="padding-left: 4em;"> |
| 3308 |
SYMBOL – for symbols</div> |
| 3309 |
<div style="padding-left: 4em;"> OBJECT – for objects</div> |
| 3310 |
<div style="padding-left: 4em;"> CONS – for conses</div> |
| 3311 |
<div style="padding-left: 4em;"> SUBR – for built-in functions</div> |
| 3312 |
<div style="padding-left: 4em;"> FSUBR – for special forms</div> |
| 3313 |
<div style="padding-left: 4em;"> CLOSURE – for defined functions</div> |
| 3314 |
<div style="padding-left: 4em;"> STRING – for strings</div> |
| 3315 |
<div style="padding-left: 4em;"> FIXNUM – for integers</div> |
| 3316 |
<div style="padding-left: 4em;"> FLONUM – for floating point numbers</div> |
| 3317 |
<div style="padding-left: 4em;"> CHARACTER – for characters</div> |
| 3318 |
<div style="padding-left: 4em;"> FILE-STREAM – for file pointers</div> |
| 3319 |
<div style="padding-left: 4em;"> UNNAMED-STREAM – for unnamed streams</div> |
| 3320 |
<div style="padding-left: 4em;"> ARRAY – for arrays<br> |
| 3321 |
|
| 3322 |
</div> |
| 3323 |
</div> |
| 3324 |
<br> |
| 3325 |
<code>peek<a name="index1848"></a>(<i>addrs</i>)</code> [SAL]<br> |
| 3326 |
<code>(peek <tt><i>addrs</i></tt>)</code> [LISP] – peek at a location in memory<br> |
| 3327 |
|
| 3328 |
|
| 3329 |
</div><div style="padding-left: 2em;"> |
| 3330 |
<i>addrs</i> – the address to peek at (integer)</div> |
| 3331 |
<div style="padding-left: 2em;"> returns – the value at the specified address (integer)<br> |
| 3332 |
|
| 3333 |
</div> |
| 3334 |
<br> |
| 3335 |
<code>poke<a name="index1849"></a>(<i>addrs</i>, <i>value</i>)</code> [SAL]<br> |
| 3336 |
<code>(poke <tt><i>addrs</i></tt> <tt><i>value</i></tt>)</code> [LISP] – poke a value into memory<br> |
| 3337 |
|
| 3338 |
|
| 3339 |
</div><div style="padding-left: 2em;"> |
| 3340 |
<i>addrs</i> – the address to poke (integer)</div> |
| 3341 |
<div style="padding-left: 2em;"> <i>value</i> – the value to poke into the address (integer)</div> |
| 3342 |
<div style="padding-left: 2em;"> returns – the value<br> |
| 3343 |
|
| 3344 |
</div> |
| 3345 |
<br> |
| 3346 |
<code>bigendianp<a name="index1850"></a>()</code> [SAL]<br> |
| 3347 |
<code>(bigendianp<a name="index1851"></a><a name="index1852"></a><a name="index1853"></a>)</code> [LISP] – is this a big-endian machine?<br> |
| 3348 |
|
| 3349 |
|
| 3350 |
</div><div style="padding-left: 2em;"> |
| 3351 |
returns – T if this a big-endian architecture, storing the high-order byte of an integer at the lowest byte address of the integer; otherwise, NIL.</div> |
| 3352 |
<div style="padding-left: 2em;"> This is not part of standard XLISP.<br> |
| 3353 |
|
| 3354 |
</div> |
| 3355 |
<br> |
| 3356 |
<code>address-of<a name="index1854"></a>(<i>expr</i>)</code> [SAL]<br> |
| 3357 |
<code>(address-of <tt><i>expr</i></tt>)</code> [LISP] – get the address of an xlisp node<br> |
| 3358 |
|
| 3359 |
|
| 3360 |
</div><div style="padding-left: 2em;"> |
| 3361 |
<i>expr</i> – the node</div> |
| 3362 |
<div style="padding-left: 2em;"> returns – the address of the node (integer)<br> |
| 3363 |
|
| 3364 |
</div> |
| 3365 |
<br> |
| 3366 |
<code>exit<a name="index1855"></a>()</code> [SAL]<br> |
| 3367 |
<code>(exit)</code> [LISP] –<br> |
| 3368 |
|
| 3369 |
exit xlisp. (Note: in Audacity plug-ins, <code>exit</code> is<br> |
| 3370 |
|
| 3371 |
undefined because exiting would terminate Audacity.)<br> |
| 3372 |
|
| 3373 |
|
| 3374 |
</div><div style="padding-left: 2em;"> |
| 3375 |
returns – never returns<br> |
| 3376 |
|
| 3377 |
</div> |
| 3378 |
<br> |
| 3379 |
<code>setup-console<a name="index1856"></a>()</code> [SAL]<br> |
| 3380 |
<code>(setup-console<a name="index1857"></a>)</code> [LISP] – set default console attributes<br> |
| 3381 |
|
| 3382 |
|
| 3383 |
</div><div style="padding-left: 2em;"> |
| 3384 |
returns – NIL</div> |
| 3385 |
<div style="padding-left: 2em;">Note: Under Windows, Nyquist normally starts up in a medium-sized console window with black text and a white background, with a window title of “Nyquist.” This is normally accomplished by calling <code>setup-console</code> in <code>system.lsp</code>. In Nyquist, you can avoid this behavior by setting <code>*setup-console*</code> to NIL in your <code>init.lsp</code> file. If <code>setup-console</code> is not called, Nyquist uses standard input and output as is. This is what you want if you are running Nyquist inside of emacs, for example.<a name="index1858"></a><br> |
| 3386 |
|
| 3387 |
</div> |
| 3388 |
<br> |
| 3389 |
<code>echoenabled<a name="index1859"></a>(<i>flag</i>)</code> [SAL]<br> |
| 3390 |
<code>(echoenabled<a name="index1860"></a> <tt><i>flag</i></tt>)</code> [LISP] – turn console input echoing on or off<br> |
| 3391 |
|
| 3392 |
|
| 3393 |
</div><div style="padding-left: 2em;"> |
| 3394 |
<i>flag</i> – T to enable echo, NIL to disable</div> |
| 3395 |
<div style="padding-left: 2em;"> returns – NIL</div> |
| 3396 |
<div style="padding-left: 2em;">Note: This function is only implemented under Linux and Mac OS X. If Nyquist I/O is redirected through pipes,<br> |
| 3397 |
|
| 3398 |
the Windows version does not echo the input, but the Linux and Mac versions do. You can turn off echoing with<br> |
| 3399 |
|
| 3400 |
this function. Under windows it is defined to do nothing.<br> |
| 3401 |
|
| 3402 |
</div> |
| 3403 |
</div> |
| 3404 |
</p> |
| 3405 |
<a name = "260"><h3>File I/O Functions</h3></a><a name="index1861"></a><a name = "261"><h4>Input from a File</h4></a><a name="index1862"></a> |
| 3406 |
<p>To open a file for input, use the <code>open</code> function with the keyword |
| 3407 |
argument <code>:direction</code> set to <code>:input</code>. To open a file for output, |
| 3408 |
use the <code>open</code> function with the keyword argument <code>:direction</code> set |
| 3409 |
to <code>:output</code>. The <code>open</code> function takes a single required argument which |
| 3410 |
is the name of the file to be opened. This name can be in the form of a |
| 3411 |
string or a symbol. The <code>open</code> function returns an object of type |
| 3412 |
<code>FILE-STREAM</code> if it succeeds in opening the specified file. It returns the |
| 3413 |
value <code>nil</code> if it fails. In order to manipulate the file, it is |
| 3414 |
necessary to save the value returned by the <code>open</code> function. This is |
| 3415 |
usually done by assigning it to a variable with the <code>setq</code> special form or by |
| 3416 |
binding it using <code>let</code> or <code>let*</code>. Here is an example: |
| 3417 |
</p> |
| 3418 |
<pre> |
| 3419 |
(setq fp (open "init.lsp" :direction :input)) |
| 3420 |
</pre> |
| 3421 |
|
| 3422 |
<p> |
| 3423 |
Evaluating this expression will result in the file <code>init.lsp</code> |
| 3424 |
being opened. The file object that will be returned by the <code>open</code> |
| 3425 |
function will be assigned to the variable <code>fp</code>.</p> |
| 3426 |
|
| 3427 |
<p> It is now possible to use the file for input. To read an |
| 3428 |
expression from the file, just supply the value of the <code>fp</code> |
| 3429 |
variable as the optional <i>stream</i> argument to <code>read</code>. |
| 3430 |
</p> |
| 3431 |
<pre> |
| 3432 |
(read fp) |
| 3433 |
</pre> |
| 3434 |
|
| 3435 |
<p> |
| 3436 |
Evaluating this expression will result in reading the first |
| 3437 |
expression from the file <code>init.lsp</code>. The expression will be |
| 3438 |
returned as the result of the <code>read</code> function. More expressions |
| 3439 |
can be read from the file using further calls to the <code>read</code> |
| 3440 |
function. When there are no more expressions to read, the <code>read</code> |
| 3441 |
function will return <code>nil</code> (or whatever value was supplied as the |
| 3442 |
second argument to <code>read</code>).</p> |
| 3443 |
|
| 3444 |
<p> Once you are done reading from the file, you should close it. |
| 3445 |
To close the file, use the following expression: |
| 3446 |
</p> |
| 3447 |
<pre> |
| 3448 |
(close fp) |
| 3449 |
</pre> |
| 3450 |
|
| 3451 |
<p> |
| 3452 |
Evaluating this expression will cause the file to be closed.</p> |
| 3453 |
<a name = "262"><h4>Output to a File</h4></a><a name="index1863"></a> |
| 3454 |
<p> Writing to a file is pretty much the same as reading from one. |
| 3455 |
You need to open the file first. This time you should use the |
| 3456 |
<code>open</code> function to indicate that you will do output to the file. |
| 3457 |
For example: |
| 3458 |
</p> |
| 3459 |
<pre> |
| 3460 |
(setq fp (open "test.dat" :direction :output)) |
| 3461 |
</pre> |
| 3462 |
|
| 3463 |
<p> |
| 3464 |
Evaluating this expression will open the file <code>test.dat</code> for |
| 3465 |
output. If the file already exists, its current contents will |
| 3466 |
be discarded. If it doesn't already exist, it will be created. |
| 3467 |
In any case, a <code>FILE-STREAM</code> object will be returned by the <code>OPEN</code> |
| 3468 |
function. This file object will be assigned to the <code>fp</code> |
| 3469 |
variable.</p> |
| 3470 |
|
| 3471 |
<p> It is now possible to write to this file by supplying the value |
| 3472 |
of the <code>fp</code> variable as the optional <i>stream</i> parameter in the <code>print</code> function. |
| 3473 |
</p> |
| 3474 |
<pre> |
| 3475 |
(print "Hello there" fp) |
| 3476 |
</pre> |
| 3477 |
|
| 3478 |
<p> |
| 3479 |
Evaluating this expression will result in the string “Hello |
| 3480 |
there” being written to the file <code>test.dat</code>. More data can be |
| 3481 |
written to the file using the same technique.</p> |
| 3482 |
|
| 3483 |
<p> Once you are done writing to the file, you should close it. |
| 3484 |
Closing an output file is just like closing an input file. |
| 3485 |
</p> |
| 3486 |
<pre> |
| 3487 |
(close fp) |
| 3488 |
</pre> |
| 3489 |
|
| 3490 |
<p> |
| 3491 |
Evaluating this expression will close the output file and make |
| 3492 |
it permanent.</p> |
| 3493 |
<a name = "263"><h4>A Slightly More Complicated File Example</h4></a> |
| 3494 |
<p> This example shows how to open a file, read each Lisp expression |
| 3495 |
from the file and print it. It demonstrates the use of files |
| 3496 |
and the use of the optional <i>stream</i> argument to the <code>read</code> |
| 3497 |
function. |
| 3498 |
</p> |
| 3499 |
<pre> |
| 3500 |
(do* ((fp (open "test.dat" :direction :input)) |
| 3501 |
(ex (read fp) (read fp))) |
| 3502 |
((null ex) nil) |
| 3503 |
(print ex)) |
| 3504 |
</pre> |
| 3505 |
|
| 3506 |
<p> |
| 3507 |
|
| 3508 |
<hr> |
| 3509 |
<a href = "part18.html">Previous Section</a> | <a href = "indx.html">Next Section (Index)</a> | <a href = "title.html#toc">Table of Contents</a> | <a href = "title.html">Title Page</a> |
| 3510 |
</body></html> |