| 1 |
<html><head><title>XLISP: An Object-oriented Lisp</title></head> |
| 2 |
|
| 3 |
<style type="text/css"> |
| 4 |
pre.example { |
| 5 |
color: #000000; |
| 6 |
background-color: #F5F5F5; |
| 7 |
padding: 8px; |
| 8 |
border: #808080; |
| 9 |
border-style: solid; |
| 10 |
border-width: 1px; |
| 11 |
width:auto; |
| 12 |
} |
| 13 |
td.button { |
| 14 |
color: #000000; |
| 15 |
background-color: #F5F5F5; |
| 16 |
padding-top: 1px; |
| 17 |
padding-bottom: 1px; |
| 18 |
padding-left: 4px; |
| 19 |
padding-right: 8px; |
| 20 |
border: #808080; |
| 21 |
border-style: solid; |
| 22 |
border-width: 1px; |
| 23 |
width:auto; |
| 24 |
} |
| 25 |
</style> |
| 26 |
|
| 27 |
<body> |
| 28 |
|
| 29 |
<a href="../start.htm">XLISP</a> > |
| 30 |
<a href="xlisp-man-index.htm">XLISP 2.0</a> - |
| 31 |
<a href="contents.htm#34">Contents</a> - |
| 32 |
<a href="../reference/reference-index.htm">Reference</a> - |
| 33 |
<a href="xlisp-man-032.htm">Previous</a> | |
| 34 |
<a href="xlisp-man-index.htm">Next</a> |
| 35 |
|
| 36 |
<hr> |
| 37 |
|
| 38 |
<h1>33 Nyquist Functions</h1> |
| 39 |
|
| 40 |
<hr> |
| 41 |
|
| 42 |
<ol> |
| 43 |
<li><nobr><a href="#predicate-functions">Predicate Functions</a></nobr></li> |
| 44 |
<ul> |
| 45 |
<li><nobr><a href="#filep">filep</a> - is this a file ?</nobr></li> |
| 46 |
</ul> |
| 47 |
<li><nobr><a href="#arithmetic-functions">Arithmetic Functions</a></nobr></li> |
| 48 |
<ul> |
| 49 |
<li><nobr><a href="#rrandom">rrandom</a> - compute a random real number between 0 and 1 inclusive</li> |
| 50 |
</ul> |
| 51 |
<li><nobr><a href="#string-functions">String Functions</a></nobr></li> |
| 52 |
<ul> |
| 53 |
<li><nobr><a href="#string-search">string-search</a> - search for pattern in string</nobr></li> |
| 54 |
</ul> |
| 55 |
<li><nobr><a href="#file-io-functions">File I/O Functions</a></nobr></li> |
| 56 |
<ul> |
| 57 |
<li><nobr><a href="#open-binary">open-binary</a> - open a binary file stream</nobr></li> |
| 58 |
<li><nobr><a href="#setdir">setdir</a> - set current directory</nobr></li> |
| 59 |
<li><nobr><a href="#listdir">listdir</a> - get a directory listing</nobr></li> |
| 60 |
<li><nobr><a href="#get-temp-path">get-temp-path</a> - get a path where a temporary file can be created</nobr></li> |
| 61 |
<li><nobr><a href="#read-int">read-int</a> - read a binary integer from a stream</nobr></li> |
| 62 |
<li><nobr><a href="#write-int">write-int</a> - write a binary integer to a stream</nobr></li> |
| 63 |
<li><nobr><a href="#read-float">read-float</a> - read a binary floating-point number from a stream</nobr></li> |
| 64 |
<li><nobr><a href="#write-float">write-float</a> - write a binary floating-point number to a stream</nobr></li> |
| 65 |
</ul> |
| 66 |
<li><nobr><a href="#system-functions">System Functions</a></nobr></li> |
| 67 |
<ul> |
| 68 |
<li><nobr><a href="#info">info</a> - show information about memory usage</nobr></li> |
| 69 |
<li><nobr><a href="#bigendiap">bigendiap</a> - is this a big-endian machine ?</nobr></li> |
| 70 |
<li><nobr><a href="#setup-console">setup-console</a> - set default console attributes</nobr></li> |
| 71 |
<li><nobr><a href="#echoenabled">echoenabled</a> - turn console input echoing on or off</nobr></li> |
| 72 |
</ul> |
| 73 |
<li><nobr><a name="11" href="#profiling">Profiling</a></nobr></li> |
| 74 |
<ul> |
| 75 |
<li><nobr><a href="#profile">profile</a> - turn profiling on or off</nobr></li> |
| 76 |
</ul> |
| 77 |
</ol> |
| 78 |
|
| 79 |
<p><b>Note:</b> if you're interested in *all* functions added by Nyquist to |
| 80 |
the XLISP language, I suggest you download the Nyquist manual from:</p> |
| 81 |
|
| 82 |
<ul> |
| 83 |
<li><a href="http://www.cs.cmu.edu/~music/music.software.html" |
| 84 |
>http://www.cs.cmu.edu/~music/music.software.html</a></li> |
| 85 |
</ul> |
| 86 |
|
| 87 |
<p>The following is a list of all Nyquist functions I have found in the |
| 88 |
XLISP section of the <nobr>Nyquist 2.36</nobr> manual but I cannot even |
| 89 |
guarantee that the list is complete. I'm willing to add more functions here |
| 90 |
if you find that some are missing but the best information source is the |
| 91 |
Nyquist manual itself. Roger is always a step ahead and I do not want to |
| 92 |
spread obsolete or wrong information.</p> |
| 93 |
|
| 94 |
<a name="predicate-functions"></a> |
| 95 |
|
| 96 |
<hr> |
| 97 |
|
| 98 |
<h2>Predicate Functions</h2> |
| 99 |
|
| 100 |
<hr> |
| 101 |
|
| 102 |
<a name="filep"></a> |
| 103 |
|
| 104 |
<dl> |
| 105 |
|
| 106 |
<dt>(filep <i>expr</i>) - is this a <nobr>file ?</nobr></dt> |
| 107 |
<dd><i>expr</i> - the expression to check<br> |
| 108 |
returns - T if the value is an object, NIL otherwise</dd> |
| 109 |
|
| 110 |
</dl> |
| 111 |
|
| 112 |
<p><nobr> <a href="#top">Back to Top</a></nobr></p> |
| 113 |
|
| 114 |
<a name="debugging-functions"></a> |
| 115 |
|
| 116 |
<hr> |
| 117 |
|
| 118 |
<h2>Arithmetic Functions</h2> |
| 119 |
|
| 120 |
<hr> |
| 121 |
|
| 122 |
<a name="rrandom"></a> |
| 123 |
|
| 124 |
<dl> |
| 125 |
|
| 126 |
<dt>(rrandom) - compute a random real number between 0 and 1 inclusive</dt> |
| 127 |
<dd>returns - a random floating point number</dd> |
| 128 |
|
| 129 |
</dl> |
| 130 |
|
| 131 |
<p><nobr> <a href="#top">Back to Top</a></nobr></p> |
| 132 |
|
| 133 |
<a name="string-functions"></a> |
| 134 |
|
| 135 |
<hr> |
| 136 |
|
| 137 |
<h2>String Functions</h2> |
| 138 |
|
| 139 |
<hr> |
| 140 |
|
| 141 |
<a name="string-search"></a> |
| 142 |
|
| 143 |
<dl> |
| 144 |
|
| 145 |
<dt>(string-search <i>pat</i> <i>str</i> &key :start :end) |
| 146 |
- search for pattern in string</dt><dd> |
| 147 |
<i>pat</i> - a string to search for<br> |
| 148 |
<i>str</i> - the string to be searched<br> |
| 149 |
:start - the starting offset in str<br> |
| 150 |
:end - the ending offset + 1<br> |
| 151 |
returns - index of <i>pat</i> in <i>str</i> or NIL if not found</dd> |
| 152 |
|
| 153 |
</dl> |
| 154 |
|
| 155 |
<p><nobr> <a href="#top">Back to Top</a></nobr></p> |
| 156 |
|
| 157 |
<a name="file-io-functions"></a> |
| 158 |
|
| 159 |
<hr> |
| 160 |
|
| 161 |
<h2>File I/O Functions</h2> |
| 162 |
|
| 163 |
<hr> |
| 164 |
|
| 165 |
<a name="open-binary"></a> |
| 166 |
|
| 167 |
<p><b>Note:</b> Files are ordinarily opened as text. Binary files [such |
| 168 |
as standard MIDI files] must be opened with 'open-binary' on non-unix |
| 169 |
systems.</p> |
| 170 |
|
| 171 |
<dl> |
| 172 |
|
| 173 |
<dt>(open-binary <i>fname</i> &key :direction) - open a binary file stream</dt> |
| 174 |
<dd><i>fname</i> - the file name string or symbol<br> |
| 175 |
:direction - :input or :output [default is :input]<br> |
| 176 |
returns - a stream</dd> |
| 177 |
|
| 178 |
<a name="setdir"></a><br> |
| 179 |
|
| 180 |
<dt>(setdir <i>path</i>) - set current directory</dt> |
| 181 |
<dd><i>path</i> - the path of the new directory<br> |
| 182 |
returns - the resulting full path, e.g. (setdir ".") gets the current |
| 183 |
working directory, or NIL if an error occurs</dd> |
| 184 |
|
| 185 |
<a name="listdir"></a><br> |
| 186 |
|
| 187 |
<dt>(listdir <i>path</i>) - get a directory listing</dt> |
| 188 |
<dd><i>path</i> - the path of the directory to be listed<br> |
| 189 |
returns - list of filenames in the directory</dd> |
| 190 |
|
| 191 |
<a name="get-temp-path"></a><br> |
| 192 |
|
| 193 |
<dt>(get-temp-path) - get a path where a temporary file can be created</dt> |
| 194 |
<dd>returns - the resulting full path as a string</dd> |
| 195 |
|
| 196 |
</dl> |
| 197 |
|
| 198 |
<p><b>Note:</b> Under Windows, the 'get-temp-path' function is based on |
| 199 |
environment variables. If XLISP is running as a sub-process to Java, the |
| 200 |
environment may not exist, in which case the default result is the |
| 201 |
unfortunate choice 'c:\windows\'.</p> |
| 202 |
|
| 203 |
<dl> |
| 204 |
|
| 205 |
<a name="read-int"></a> |
| 206 |
|
| 207 |
<dt>(read-int [<i>stream</i> [<i>length</i>]]) - read a binary integer from a stream</dt> |
| 208 |
<dd><i>stream</i> - the input stream [default is standard input]<br> |
| 209 |
<i>length</i> - the length of the integer in bytes [default is 4]<br> |
| 210 |
returns - the integer</dd> |
| 211 |
|
| 212 |
<a name="write-int"></a><br> |
| 213 |
|
| 214 |
<dt>(write-int <i>ch</i> [<i>stream</i> [<i>length</i>]]) - write a binary integer to a stream</dt> |
| 215 |
<dd><i>ch</i> - the character to write<br> |
| 216 |
<i>stream</i> - the output stream [default is standard output]<br> |
| 217 |
<i>length</i> - the length of the integer in bytes [default is 4]<br> |
| 218 |
returns - the integer</dd> |
| 219 |
|
| 220 |
<a name="read-float"></a><br> |
| 221 |
|
| 222 |
<dt>(read-float [<i>stream</i> [<i>length</i>]]) - read a binary |
| 223 |
floating-point number from a stream</dt> |
| 224 |
<dd><i>stream</i> - the input stream (default is standard input)<br> |
| 225 |
<i>length</i> - the length of the float in bytes [default is 4, |
| 226 |
legal values are -4, -8, 4, and 8]<br> |
| 227 |
returns - the float</dd> |
| 228 |
|
| 229 |
<a name="write-float"></a><br> |
| 230 |
|
| 231 |
<dt>(write-float <i>ch</i> [<i>stream</i> [<i>length</i>]]) - write a binary floating-point number to a stream</dt> |
| 232 |
<dd><i>ch</i> - the character to write<br> |
| 233 |
<i>stream</i> - the output stream [default is standard output]<br> |
| 234 |
<i>length</i> - the length of the float in bytes [default is 4, |
| 235 |
legal values are -4, -8, 4, and 8]<br> |
| 236 |
returns - the float</dd> |
| 237 |
|
| 238 |
</dl> |
| 239 |
|
| 240 |
<p><b>Note:</b> Integers and floats are assumed to be big-endian [high-order |
| 241 |
byte first] and signed, regardless of the platform. To read little-endian |
| 242 |
format, use a negative number for the length, e.g. '-4' indicates a 4-bytes, |
| 243 |
low-order byte first. The file should be opened in binary mode.</p> |
| 244 |
|
| 245 |
<p><nobr> <a href="#top">Back to Top</a></nobr></p> |
| 246 |
|
| 247 |
<a name="system-functions"></a> |
| 248 |
|
| 249 |
<hr> |
| 250 |
|
| 251 |
<h2>System Functions</h2> |
| 252 |
|
| 253 |
<hr> |
| 254 |
|
| 255 |
<p><b>Note:</b> in Nyquist, the XLISP |
| 256 |
<a href="../reference/load.htm">load</a> function first tries to |
| 257 |
load a file from the current directory. A '.lsp' extension is added if there |
| 258 |
is not already an alphanumeric extension following a period. If that fails, |
| 259 |
XLISP searches the path, which is obtained from the XLISPPATH environment |
| 260 |
variable in Unix and HKEY_LOCAL_MACHINE\SOFTWARE\CMU\Nyquist\XLISPPATH under |
| 261 |
Win32. [The Macintosh version has no search path.]</p> |
| 262 |
|
| 263 |
<a name="info"></a> |
| 264 |
|
| 265 |
<dl> |
| 266 |
<dt>(info) - show information about memory usage.</dt> |
| 267 |
<dd>returns - NIL</dd> |
| 268 |
</dl> |
| 269 |
|
| 270 |
<a name="bigendiap"></a> |
| 271 |
|
| 272 |
<dl> |
| 273 |
<dt>(bigendiap) - is this a big-endian <nobr>machine ?</nobr></dt> |
| 274 |
<dd>returns - T if this a big-endian architecture, storing the high-order |
| 275 |
byte of an integer at the lowest byte address of the integer, otherwise |
| 276 |
NIL.</dd> |
| 277 |
</dl> |
| 278 |
|
| 279 |
<p><b>Note:</b> Under Windows, Nyquist normally starts up in a medium-sized |
| 280 |
console window with black text and a white background, with a window title |
| 281 |
of "Nyquist." This is normally accomplished by calling 'setup-console' in |
| 282 |
'system.lsp'. In Nyquist, you can avoid this behavior by setting |
| 283 |
*setup-console* to NIL in your 'init.lsp' file. If 'setup-console' is not |
| 284 |
called, Nyquist uses standard input and output as is. This is what you want |
| 285 |
if you are running Nyquist inside of emacs, for example.</p> |
| 286 |
|
| 287 |
<a name="setup-console"></a> |
| 288 |
|
| 289 |
<dl> |
| 290 |
<dt>(setup-console) - set default console attributes</dt> |
| 291 |
<dd>returns - NIL</dd> |
| 292 |
</dl> |
| 293 |
|
| 294 |
<p><b>Note:</b> The 'echoenabled' function is only implemented under Linux |
| 295 |
and <nobr>Mac OS X.</nobr> If Nyquist I/O is redirected through pipes, the |
| 296 |
Windows version does not echo the input, but the Linux and Mac versions do. |
| 297 |
You can turn off echoing with this function. Under windows it is defined to |
| 298 |
do nothing.</p> |
| 299 |
|
| 300 |
<a name="echoenabled"></a> |
| 301 |
|
| 302 |
<dl> |
| 303 |
<dt>(echoenabled <i>flag</i>) - turn console input echoing on or off</dt> |
| 304 |
<dd><i>flag</i> - T to enable echo, NIL to disable<br> |
| 305 |
returns - NIL</dd> |
| 306 |
</dl> |
| 307 |
|
| 308 |
<p><nobr> <a href="#top">Back to Top</a></nobr></p> |
| 309 |
|
| 310 |
<a name="profiling"></a> |
| 311 |
|
| 312 |
<hr> |
| 313 |
|
| 314 |
<h1>Profiling</h1> |
| 315 |
|
| 316 |
<hr> |
| 317 |
|
| 318 |
<p>The Xlisp 2.0 release has been extended with a profiling facility, which |
| 319 |
counts how many times and where |
| 320 |
<a href="../reference/eval.htm">eval</a> is executed. A separate |
| 321 |
count is maintained for each named function, closure, or macro, and a count |
| 322 |
indicates an <a href="../reference/eval.htm">eval</a> in the |
| 323 |
immediately [lexically] enclosing named function, closure, or macro. Thus, |
| 324 |
the count gives an indication of the amount of time spent in a function, not |
| 325 |
counting nested function calls.</p> |
| 326 |
|
| 327 |
<p>The list of all functions executed is maintained on the global *profile* |
| 328 |
variable. These functions in turn have *profile* properties, which maintain |
| 329 |
the counts. The profile system merely increments counters and puts symbols |
| 330 |
on the *profile* list. It is up to the user to initialize data and gather |
| 331 |
results. Profiling is turned on or off with the 'profile' function.</p> |
| 332 |
|
| 333 |
<a name="profile"></a> |
| 334 |
|
| 335 |
<dl> |
| 336 |
<dt>(profile <i>flag</i>) - turn profiling on or off</dt> |
| 337 |
<dd><i>flag</i> - NIL turns profiling off, otherwise on<br> |
| 338 |
returns - the previous state of profiling</dd> |
| 339 |
</dl> |
| 340 |
|
| 341 |
<p>Unfortunately, methods cannot be profiled with this facility.</p> |
| 342 |
|
| 343 |
<p>[Nyquist sources: xlsys.c, xleval.c]</p> |
| 344 |
|
| 345 |
<p> <a href="#top">Back to Top</a></p> |
| 346 |
|
| 347 |
<hr> |
| 348 |
|
| 349 |
<a href="../start.htm">XLISP</a> > |
| 350 |
<a href="xlisp-man-index.htm">XLISP 2.0</a> - |
| 351 |
<a href="contents.htm#34">Contents</a> - |
| 352 |
<a href="../reference/reference-index.htm">Reference</a> - |
| 353 |
<a href="xlisp-man-032.htm">Previous</a> | |
| 354 |
<a href="xlisp-man-index.htm">Next</a> |
| 355 |
|
| 356 |
</body></html> |