This file is indexed.

/usr/share/doc/yacas-doc/html/introchapter3.html is in yacas-doc 1.3.3-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
<html>
<head>
  <title>Running Yacas off-line</title>
  <link rel="stylesheet" href="yacas.css" TYPE="text/css" MEDIA="screen">
</head>
<body>
<a name="c3">

</a>
(directly go to documentation on : <a href="introchapter3.html#quit" target='Chapters' title="stop Yacas from running, from the command line">quit</a>, <a href="introchapter3.html#restart" target='Chapters' title="restart Yacas (to start with a clean slate)">restart</a>.
)<h1>
3. Running Yacas off-line
</h1>

This section describes the special commands for the Yacas interactive sessions (for example, to restart or to exit the interpreter).
These commands are not functions but special directives that only apply while running Yacas interactively.
They should not be used in scripts.

<p> </p>
<center><table>
<tr BGCOLOR=#E0E0E0>
<td><a href="introchapter3.html#quit" target='Chapters' title="stop Yacas from running, from the command line">quit</a></td>
<td>stop Yacas from running, from the command line</td>
</tr>
<tr BGCOLOR=#E0E0E0>
<td><a href="introchapter3.html#restart" target='Chapters' title="restart Yacas (to start with a clean slate)">restart</a></td>
<td>restart Yacas (to start with a clean slate)</td>
</tr>
</table></center>
<a name="c3s1">

</a>
<h2>
<hr>3.1 Interactive session commands
</h2>

<p>

<a name="quit">

</a>
<a name="quit">

</a>
<h3>
<hr>quit -- stop Yacas from running, from the command line
</h3>
<a name="restart">

</a>
<a name="restart">

</a>
<h3>
<hr>restart -- restart Yacas (to start with a clean slate)
</h3>
<h5 align=right>Internal function</h5><h5>
Calling format:
</h5>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
quit
restart
</pre></tr>
</table>


<p>

<h5>
Description:
</h5>
Type <b><tt>quit</tt></b> or <b><tt>restart</tt></b> at the Yacas prompt to exit or to restart the interpreter.


<p>
The directives <b><tt>quit</tt></b> and <b><tt>restart</tt></b> are <i>not</i> reserved words or variable names.
They take effect only when typed as first characters at a prompt.


<p>
Pressing <b><tt>Ctrl-C</tt></b> will stop the currently running calculation.
If there is no currently running calculation, <b><tt>Ctrl-C</tt></b> will quit the interpreter.


<p>
When the interpreter quits, it saves the command history
(so quitting by <b><tt>Ctrl-C</tt></b> does not mean a "crash").


<p>

<h5>
Examples:
</h5>
To be effective, the directive must be typed immediately after the prompt:
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
In&gt; quit
Quitting...
</pre></tr>
</table>
We can use variables named <b><tt>quit</tt></b>:
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
In&gt; 1+quit
Out&gt; quit+1;
</pre></tr>
</table>
There is no effect if we type some spaces first: 
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
In&gt;       restart
Out&gt; restart;
</pre></tr>
</table>


<p>

<h5>
See also:
</h5>
<a href="ref.html?Exit" target="Chapters">
Exit
</a>
.<a name="c3s2">

</a>
<h2>
<hr>3.2 Command-line options
</h2>
<a name="options">

</a>

<p>

<a name="command-line options!summary">

</a>
The default operation of <b><tt>Yacas</tt></b> is to run in the interactive console mode. <b><tt>Yacas</tt></b> accepts several options that modify its operation.
Here is a summary of options:


<p>
<ul><li></li><i>filename</i> ... (read and execute a file or several files)
<li></li><b><tt>-c</tt></b> (omit line prompts)
<li></li><b><tt>-d</tt></b> (print default directory)
<li></li><b><tt>-v</tt></b> (print version information)
<li></li><b><tt>-f</tt></b> (execute standard input as one statement)
<li></li><b><tt>-p</tt></b> (do not use terminal capabilities)
<li></li><b><tt>-t</tt></b> (enable extra history features)
<li></li><b><tt>--archive</tt></b> <i>filename</i> (use a given library archive file)
<li></li><b><tt>--init</tt></b> <i>filename</i> (use a given initial file)
<li></li><b><tt>--patchload</tt></b> (use <b><tt>PatchLoad</tt></b> to load files)
<li></li><b><tt>--read-eval-print</tt></b> <i>expression</i> (call this expression for the read-eval-print loop)
<li></li><b><tt>--rootdir</tt></b> <i>directory</i> (specify default directory for scripts)
<li></li><b><tt>--server</tt></b> <i>port</i> (start <b><tt>Yacas</tt></b> as a network server on given port)
<li></li><b><tt>--single-user-server</tt></b> (If in server mode, start it in single-user mode)
<li></li><b><tt>--verbose-debug</tt></b> (turn on showing some additional debugging information on screen)
<li></li><b><tt>--disable-compiled-plugins</tt></b> (disable loading of compiled plugins, loading the script versions instead)
<li></li><b><tt>--stacksize</tt></b> <i>size</i> (change size of stack arguments are stored on)
<li></li><b><tt>--execute</tt></b> <i>expression</i> (run expression from the command line)
</ul>

<p>
Options can be combined, for example
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas -pc filename
</pre></tr>
</table>
will read and execute the file <b><tt>filename</tt></b> non-interactively without using terminal capabilities and without printing prompts.


<p>
Here is a more detailed description of the command-line options.


<p>

<a name="command-line options">

</a>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas -c
</pre></tr>
</table>
Inhibit printing of prompts <b><tt>In&gt;</tt></b> and <b><tt>Out&gt;</tt></b>. Useful for non-interactive sessions.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas -f
</pre></tr>
</table>
Reads standard input as one file, but executes only the first statement in it. (You may want to use a statement block to have several statements executed.)


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas -p
</pre></tr>
</table>
Does not use terminal capabilities, no fancy editing on the command line and no escape sequences printed. Useful for non-interactive sessions.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas -t
</pre></tr>
</table>
Enable some extra history recall functionality in console mode: after executing a command from the history list, the next unmodified command from the history list will be automatically entered on the command line.


<p>

<a name="executing script files">

</a>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas [options] {filename}
</pre></tr>
</table>
Reads and executes commands in the filename and exits. Equivalent to <b><tt>Load()</tt></b>.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas -v
</pre></tr>
</table>
Prints version information and exits.
(This is the same information as returned by <b><tt>Version()</tt></b>.)


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas -d
</pre></tr>
</table>
Prints the path to the <b><tt>Yacas</tt></b> default library directory (this information is compiled into the <b><tt>Yacas</tt></b> executable) and exits.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --patchload
</pre></tr>
</table>
Will load every file on the command line with the <b><tt>PatchLoad</tt></b> command instead of the normal <b><tt>Load</tt></b> command,
This is useful for generating HTML pages for a
web site using the <b><tt>Yacas</tt></b> scripting language, much like you can do with
the PHP scripting language.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --init [file]
</pre></tr>
</table>
Tells the system to load <b><tt>file</tt></b> as the initialization file. By default
it loads the file <b><tt>yacasinit.ys</tt></b> from the scripts directory. Thus for
customization one has two options: write a <b><tt>~/.yacasrc</tt></b> file
with initialization code (as it is loaded after the initialization
script is loaded), or write a custom initialization script that first
uses <b><tt>yacasinit.ys</tt></b> and adds some extra custom code.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --read-eval-print [expression]
</pre></tr>
</table>
Call <b><tt>expression</tt></b> for the read-eval-print loop. The default 
read-eval-print loop is implemented in the initialization 
script <b><tt>yacasinit.ys</tt></b> as the function <b><tt>REP</tt></b>.
The default behavior is therefore equivalent to <b><tt>--read-eval-print</tt></b> <b><tt>REP()</tt></b>.


<p>
There is also a fallback read-eval-print
loop in the kernel; it can be invoked by passing an empty
string to this command line option, as <b><tt>--read-eval-print ""</tt></b>.


<p>
An alternative way to replace the default read-eval-print
loop is to write a custom initialization script that implements
the read-eval-print loop function <b><tt>REP()</tt></b> instead of <b><tt>yacasinit.ys</tt></b>.


<p>
Care has to be taken with this option because a Yacas session may
become unusable if the read-eval-print expression doesn't function correctly.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --server &lt;port&gt;
</pre></tr>
</table>
On some platforms server mode can be enabled at build time by passing the
flag <b><tt>--enable-server</tt></b> to the <b><tt>./configure</tt></b> script. <b><tt>Yacas</tt></b>
then allows you to pass the flag <b><tt>--server</tt></b> with a port number
behind it, and the <b><tt>Yacas</tt></b> executable will listen to the socket
behind that port instead of waiting for user input on the console.


<p>
Commands can be sent to the server by sending a text line as
one block of data, and the server will respond back with another text block. 


<p>
One can test this function by using <b><tt>telnet</tt></b>. First, set up
the server by calling


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --server 9734
</pre></tr>
</table>
and then invoke <b><tt>telnet</tt></b> in another window, for example:
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
telnet 127.0.0.1 9734
</pre></tr>
</table>
Then type a line of Yacas input and hit Enter.
The result will be one line that you will get back from the Yacas server.


<p>
Some security measures and resource management measures have been 
taken. No more than 10 connections can be alive at any time, 
a calculation cannot take more than 30 seconds, and <b><tt>Yacas</tt></b>
operates in the <i>secure</i> mode, much like calling an expression
by passing it as an argument to the <b><tt>Secure</tt></b> function.
This means that no system calls are allowed, and no writing to
local files, amongst other things. Something that has not been 
taken care of yet is memory use. A calculation could take up all
memory, but not for longer than 30 seconds. 


<p>
The server is single-threaded, but has persistent sessions for
at most 10 users at a time, from which it can service requests
in a sequential order. To make the service multi-threaded, a
solution might be to have a proxy in front of the service listening
to the port, redirecting it to different processes which get
started up for users (this has not been tried yet).


<p>
The flag --single-user-server can be passed on to instruct <b><tt>yacas</tt></b>
to start in single-user mode. In this mode, unsecure operations can
be performed (like reading from and writing to files), and the calculation
may take more than 30 seconds. The <b><tt>yacas</tt></b> process will automatically be
shut down when the last session is closed or when "Exit();" is sent.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --rootdir [directory]
</pre></tr>
</table>
Tells the system where to find the library scripts. Here, <b><tt>directory</tt></b> is a
path that is passed to <b><tt>DefaultDirectory</tt></b>. It is also possible to give a
list of directories, separated by a colon, e.g. 
<b><tt>yacas --rootdir scripts/:morescripts/</tt></b>.
Note that it is not necessary to append a trailing slash to the directory names.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --archive [file]
</pre></tr>
</table>
Use a compressed archive instead of the script library.


<p>

<a name="using compressed libraries">

</a>
<b><tt>Yacas</tt></b> has an experimental system where files can be compressed into
one file, and accessed through this command line option. The advantages
are:


<p>
<ul><li>Smaller disk/memory use (useful if </li><b><tt>Yacas</tt></b> is used on small hand-held computers).
<li>No problems with directory path separators: "</li><b><tt>path</tt></b>/<b><tt>file</tt></b>" will always
resolve to the right file, no matter what platform (read: Windows) it runs on.
<li>The start-up time of the program might improve a little, since 
a smaller file is loaded from disk (disk access being slow), and then decompressed
in memory, which might be a lot faster than loading from disk.
</li></ul>

<p>
An additional savings is due to the fact that the script files are 
stripped from white spaces and comments, making them smaller and faster loading.


<p>
To prepare the compressed library archive, run <b><tt>./configure</tt></b>
with the command line option <b><tt>--enable-archive</tt></b>.


<p>
The result should be the archive file <b><tt>scripts.dat</tt></b>.
Then launch <b><tt>Yacas</tt></b> with the command line option <b><tt>--archive scripts.dat</tt></b>,
with the file <b><tt>scripts.dat</tt></b> in the current directory.


<p>
The reason that the <b><tt>scripts.dat</tt></b> file is not built automatically is
that it is not tested, at this time, that the build process works on all
platforms.
(Right now it works on Unix, MacOSX, and Win32.)


<p>
Alternatively, configure Yacas with
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
./configure --enable-archive
</pre></tr>
</table>
and the archive file <b><tt>scripts.dat</tt></b> will be created in the <b><tt>ramscripts/</tt></b>
subdirectory.


<p>
When an archive is present, Yacas will try to load it before it looks for scripts from the library directories.
Typing 
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
make archivetest -f makefile.compressor
</pre></tr>
</table>
in the <b><tt>ramscripts/</tt></b> directory runs all the test scripts using the archived
files.


<p>
The currently supported compression schemes are uncompressed
and compressed with <b><tt>minilzo</tt></b>. Script file stripping (removing whitespace
and comments) may be disabled by editing <b><tt>compressor.cpp</tt></b> (variable <b><tt>strip_script</tt></b>).


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --disable-compiled-plugins
</pre></tr>
</table>


<p>
Disable loading of compiled scripts, in favor of scripts themselves.
This is useful when developing the scripts that need to be compiled
in the end, or when the scripts have not been compiled yet.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --stacksize &lt;size&gt;
</pre></tr>
</table>
Yacas maintains an internal stack for arguments. For nested function calls, all arguments currently used are on this stack. The size of this stack is
50000 be  default. 


<p>
For a function that would take 4 arguments and has one return value, there would be 5 places reserved on this stack, and the function could call itself recursively 10000 steps deep.


<p>
This differs from the MaxEvalDepth mechanism. The MaxEvalDepth mechanism
allows one to specify the number of separate stack frames (number of calls, 
nested), instead of the number of arguments pushed on the stack. MaxEvalDepth
was introduced to protect the normal <b><tt>C++</tt></b> stack.


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
yacas --execute &lt;expression&gt;
</pre></tr>
</table>
This instructs Yacas to run a certain expression, passed in over the command line, before dropping to the read-eval-print loop. This can be used to load a file before dropping to the command line without exiting (if there are files to run specified on the command line, Yacas will exit after running these scripts). Alternatively, the expression can exit the interpreter immediately by calling <b><tt>Exit();</tt></b>. When used in combination with <b><tt>-pc</tt></b>, the Yacas interpreter can be used to calculate something and print the result to standard output. Example:


<p>
<table cellpadding="0" width="100%">
<tr><td width=100% bgcolor="#DDDDEE"><pre>
user% ./yacas -pc --execute '[Echo("answer ",D(x)Sin(x));Exit();]'
answer Cos(x) 
user% 
</pre></tr>
</table>


<p>


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2425144-1";
urchinTracker();
</script>
</body>

</html>