/usr/share/doc/mcl/html/mcxi.html is in mcl-doc 1:14-137-1.
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 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (c) 2014 Stijn van Dongen -->
<head>
<meta name="keywords" content="manual">
<style type="text/css">
/* START aephea.base.css */
body
{ text-align: justify;
margin-left: 0%;
margin-right: 0%;
}
a:link { text-decoration: none; }
a:active { text-decoration: none; }
a:visited { text-decoration: none; }
a:link { color: #1111aa; }
a:active { color: #1111aa; }
a:visited { color: #111166; }
a.local:link { color: #11aa11; }
a.local:active { color: #11aa11; }
a.local:visited { color: #116611; }
a.intern:link { color: #1111aa; }
a.intern:active { color: #1111aa; }
a.intern:visited { color: #111166; }
a.extern:link { color: #aa1111; }
a.extern:active { color: #aa1111; }
a.extern:visited { color: #661111; }
a.quiet:link { color: black; }
a.quiet:active { color: black; }
a.quiet:visited { color: black; }
div.verbatim
{ font-family: monospace;
margin-top: 1em;
margin-bottom: 1em;
font-size: 10pt;
margin-left: 2em;
white-space: pre;
}
div.indent
{ margin-left: 8%;
margin-right: 0%;
}
.right { text-align: right; }
.left { text-align: left; }
.nowrap { white-space: nowrap; }
.item_leader
{ position: relative;
margin-left: 8%;
}
.item_compact { position: absolute; vertical-align: baseline; }
.item_cascade { position: relative; }
.item_leftalign { text-align: left; }
.item_rightalign
{ width: 2em;
text-align: right;
}
.item_compact .item_rightalign
{ position: absolute;
width: 52em;
right: -2em;
text-align: right;
}
.item_text
{ position: relative;
margin-left: 3em;
}
.smallcaps { font-size: smaller; text-transform: uppercase }
/* END aephea.base.css */
body { font-family: "Garamond", "Gill Sans", "Verdana", sans-serif; }
body
{ text-align: justify;
margin-left: 8%;
margin-right: 8%;
}
</style>
<title>The mcxi manual</title>
</head>
<body>
<p style="text-align:right">
16 May 2014
<a class="local" href="mcxi.ps"><b>mcxi</b></a>
14-137
</p>
<div class=" itemize " style="margin-top:1em; font-size:100%">
<div class=" item_compact"><div class=" item_rightalign nowrap " style="right:-3em">1.</div></div>
<div class=" item_text " style="margin-left:4em">
<a class="intern" href="#name">NAME</a>
</div>
<div class=" item_compact"><div class=" item_rightalign nowrap " style="right:-3em">2.</div></div>
<div class=" item_text " style="margin-left:4em">
<a class="intern" href="#synopsis">SYNOPSIS</a>
</div>
<div class=" item_compact"><div class=" item_rightalign nowrap " style="right:-3em">3.</div></div>
<div class=" item_text " style="margin-left:4em">
<a class="intern" href="#description">DESCRIPTION</a>
</div>
<div class=" item_compact"><div class=" item_rightalign nowrap " style="right:-3em">4.</div></div>
<div class=" item_text " style="margin-left:4em">
<a class="intern" href="#operators">OPERATORS</a>
</div>
<div class=" item_compact"><div class=" item_rightalign nowrap " style="right:-3em">5.</div></div>
<div class=" item_text " style="margin-left:4em">
<a class="intern" href="#index">INDEX</a>
</div>
<div class=" item_compact"><div class=" item_rightalign nowrap " style="right:-3em">6.</div></div>
<div class=" item_text " style="margin-left:4em">
<a class="intern" href="#author">AUTHOR</a>
</div>
<div class=" item_compact"><div class=" item_rightalign nowrap " style="right:-3em">7.</div></div>
<div class=" item_text " style="margin-left:4em">
<a class="intern" href="#seealso">SEE ALSO</a>
</div>
</div>
<a name="name"></a>
<h2>NAME</h2>
<p style="margin-bottom:0" class="asd_par">
mcx — a stack language interpreter for interaction with the <b>mcl</b> libraries.</p>
<a name="synopsis"></a>
<h2>SYNOPSIS</h2>
<p style="margin-bottom:0" class="asd_par">
<b>mcxi</b> (enter interactive mode)
</p>
<p style="margin-bottom:0" class="asd_par">
<b>mcxi</b> <mcxi expression>
</p>
<a name="description"></a>
<h2>DESCRIPTION</h2>
<p style="margin-bottom:0" class="asd_par">
<b>mcxi</b> can be used both from the command line and interactively, and supports
a rich set of operations such as transposition, scaling, column scaling,
multiplication, Hadamard powers and products, et cetera. It has variables,
control primitives, and stack manipulation primitives.
The general aim is to support basic number and matrix arithmetic, as well as
graph, set, and clustering operations. The language will be kept simple,
and should serve only as a means of making the <b>mcl</b> framework a pleasant one
for working with graphs, matrices, clusterings, and sets.
The language is typed, and currently has the types <i>integer, real,
matrix, string, and block</i>.
Blocks are used both in control statements such as <b>ifelse</b> and
<b>while</b>, and for defining compound statements resembling procedures or
functions.
Some of <b>mcxi</b>'s primitives are overloaded. The following is a very simple
example of implementing and using <b>mcl</b> in this language.
</p>
<div class="verbatim">
2.0 .i def # define inflation value.
/small lm # load matrix in file 'small'.
dim id add # add identity matrix.
st .x def # make stochastic, bind to x.
{ xpn .i infl vm } .mcl def # define one mcl iteration.
20 .x .mcl repeat # iterate 20 times
imac # interpret matrix as clustering.
vm # view matrix (clustering).
</div>
<p style="margin-top:0em; margin-bottom:0em">
Somewhat misleadingly, '#' is not recognized as a comment
symbol by <b>mcxi</b>, so don't use it (yet).
</p>
<p style="margin-bottom:0" class="asd_par">
<b>mcxi</b> has quite a lot of primitives, and they are not all explained in here.
However, <b>mcxi</b> has several help facilities. <b>mcxi</b>'s munge modes (command
line, interactive, and file) are discussed first, followed by some syntactic
and semantic rules.
Several groups of related primitives are then discussed. These are the help
primitives <b>help</b>, <b>grep</b>, <b>ops</b>, and others,
the binding primitives <b>def</b>, <b>free</b>, and <b>unlink</b>,
the control primitives <b>ifelse</b>, <b>do</b>, <b>repeat</b>, and <b>while</b>,
and the stack manipulation primitives <b>pop</b>, <b>exch</b>, <b>dup</b>,
<b>mdup</b>, <b>copy</b>, <b>roll</b>, <b>clear</b>.
And for the record, <b>mcxi</b> has <b>lt</b>, <b>lq</b>, <b>eq</b>, <b>gq</b>, and
<b>gt</b>.
In the grandiloquently named <a class="intern" href="#index">INDEX</a> section, you find a list
of all current <b>mcxi</b> primitives.
</p>
<p style="margin-bottom:0" class="asd_par">
First, there is no difference as far as <b>mcxi</b> is concerned whether
you give it a bunch of operators and operands directly from the command
line, or whether you do it in interactive mode. Interactive mode is
line-based; each time you type a carriage return, <b>mcxi</b> starts interpreting
the line you typed. Newlines can be escaped by preceding them with a
backslash;
<b>mcxi</b> will delay interpretation and keep building up your expression.
Command line mode is the same as entering interactive mode and entering a
single line. For non-batch processing, interactive mode is the safest,
because <b>mcxi</b> will simply refuse to carry out impossible operations,
whereas in command line mode it will exit.
</p>
<p style="margin-bottom:0" class="asd_par">
In interactive mode, <b>mcxi</b> will by default list the stack after each line you
type. This is verbosity level 1. There are four verbosity levels, namely 0,
1, 2, and 3 (in increasingly verbose order). Set the level with the <b>vb</b>
primitive. Verbosity control is still a bit crude, this is one of the areas
in which <b>mcxi</b> will be improved.
</p>
<p style="margin-bottom:0" class="asd_par">
There is another <b>mcxi</b> munge mode which is entered when reading files
with the <b>lf</b> (load file) primitive. This mode is not line-based,
the whole file is interpreted in one go — there is little
difference with line-based mode. Beware though, it is currently
not possible (nor necessary) to escape newlines in files.
</p>
<p style="margin-bottom:0" class="asd_par">
Currently, <b>mcxi</b> parses lines of text into atoms in an extremely
straightforward way: Whitespace is the only separator, and it is always a
separator. This has as a consequence that the block delimiters <b>{</b> and
<b>}</b> are not allowed to appear next to a non-white character. Another
consequence is that strings cannot contain white spaces. Both these
conditions may be relaxed in the future though.
</p>
<p style="margin-bottom:0" class="asd_par">
Strings are always entered
with a leading slash, and anything with a leading slash is a string, so
<tt>/this</tt> is a string. Currently, the double quote has no special
meaning, but it may acquire meaning in the future, especially as in
<tt>/"maybe the mcxi future will be brighter"</tt>.
</p>
<p style="margin-bottom:0" class="asd_par">
Variables names are always entered with a leading dot, and anything with a
leading dot is a variable name. Variables are implicitly typed by the
object to which they are bound. There is no support for arrays (yet).
If variables are used, as in <tt>.x .y add</tt>, only the names of
the variables are popped, and the binding between the names and their
values stays intact.
</p>
<p style="margin-bottom:0" class="asd_par">
There are some operators that do in-place modification of the object that
they act on, such as <tt>infl</tt> (inflation). Currently, these are all
operators acting on matrices. When presented with a variable,
they do change the object associated with the variable.
In the built-in documentation strings (accessible with <b>help</b>
and <b>grep</b>), such in-place modification is denoted with
a prime as in <tt><m> -> <m'></tt>.
</p>
<p style="margin-bottom:0" class="asd_par">
<b>dup</b> can be used to duplicate objects. In case of variables,
this will be a copy of the variable name. If one occurrence is
used to free the associated object by some operator, all other
instances of the variable become <i>stale</i>.
<b>mcxi</b> will notice this and you will see such elements marked as stale
handles in the stack listing. <b>copy</b> can be used to copy the
object associated with a variable.
</p>
<p style="margin-bottom:0" class="asd_par">
<b>mcxi</b> is/interprets a stack language. In order to add 1 and 2 you need to
write <tt>1 2 add</tt>. When add is evaluated, it removes the previous two
items from the stack and replaces it with their sum, in this case the
integer 3.
<b>mcxi</b>'s types are denoted as <tt><int></tt>, <tt><real></tt>, <tt><mx></tt>,
<tt><str></tt>, <tt><block></tt>, and so are objects that can be of that type. An
object that is of underspecified type (such as taken by overloaded
operators) is denoted <tt><obj></tt>.
Where a variable name must occur, <tt><var></tt> is written.
In <b>mcxi</b> parlance a 'variable' is the same as 'handle'.
Remember that a variable named <tt>x</tt> is written <tt>.x</tt>, and
that a string "foo" is entered as <tt>/foo</tt> in <b>mcxi</b>.
</p>
<a name="operators"></a>
<h2>OPERATORS</h2>
<div class=" itemize " style="margin-top:1em; font-size:100%">
<div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>help</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
<b>help</b> with no arguments prints a descriptory line for each primitive.
Can only be used at bottom of stack.
Alias: <b>h</b>.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt>/str</tt> <b>help</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
<b>help</b> with argument <tt>/str</tt> prints a descriptive line for the
primitive named <tt>str</tt>. The string must be identical to the primitive's
name, or help will not show anything. Alias: <b>h</b>.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt>/str</tt> <b>grep</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Prints each descriptive line in which the string str occurs (literally).
So <tt>/matrix grep</tt> should produce a lot of matrix related
primitives (although it may miss generic primitives such as <b>add</b>
and <b>mul</b>). At bottom of stack, prints all descriptive lines.
Alias: <b>g</b>.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>ops</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Lists all primitives and aliases concisely in a paragraph.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>list</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Lists the contents of the operand stack.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>info</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Lists the top element of the operand stack.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><int></tt> <b>tell</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Lists the top <tt><int></tt> elements of the operand stack.
The trio of <b>list</b>, <b>info</b>, and <b>tell</b>
is perhaps overdoing it slightly, but anyway there it is.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>vars</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Lists all variables currently bound.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><obj></tt> <tt><var></tt> <b>def</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Bind <tt><obj></tt> to <tt><var></tt>. Redefinition is allowed.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><var></tt> <b>free</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Break the binding between <tt><var></tt> and the object it currently binds,
and remove object.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>unlink</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Break the binding between <tt><var></tt> and the object it currently binds,
and push object on the stack.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><int> <block1> <block2></tt> <b>ifelse</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
If <tt><int></tt> is nonzero execute <tt><block1></tt>,
otherwise execute <tt><block2></tt>.
The equate operators <b>lt</b>, <b>lq</b>, <b>eq</b>, <b>gq</b>, and <b>gt</b>
can be used to leave an <tt><int></tt> on the stack.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><block></tt> <b>do</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Execute <tt><block></tt> (one time).
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><int> <block></tt> <b>repeat</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Execute <tt><block></tt> <tt><int></tt> times.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><block1> <block2></tt> <b>while</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
This primitive repeatedly executes the <i>condition</i> <tt><block1></tt>,
<i>which must push an integer each time it is executed</i>. Each time, the
pushed integer is popped. If it was non-zero, <tt><block2></tt> is executed,
<tt><block1></tt> is executed, and the cycle continues. If it was zero,
<b>while</b> is done.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>pop</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Pops one element off of the stack.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>exch</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Exchanges the top two elements of the stack.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>dup</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Duplicates the top element and pushes the duplicate onto the stack. In case
of a variable, the name is duplicated and not the object it points to. In
case of anonymous matrices and strings (and whatever other (composite)
objects may emerge), a <i>deep copy</i> is made that is completely independent
of the original object.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><int></tt> <b>mdup</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Duplicates the top <tt><int></tt> elements. See the <b>dup</b> entry
above for the semantics of duplication. I wrote <b>mdup</b> because
I thought some other operator needed it, which turned out to be false.
In the meantime, I became very much attached to <b>mdup</b>,
so mail me if you think you have any useful use for it.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>copy</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Copies the top element and pushes the copy onto the stack.
In case of a variable, copies the object associated with the variable
rather than the variable's name (as <b>dup</b> would do).
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><tt><int1> <int2></tt> <b>roll</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Shift <tt><int1></tt> objects cyclically <tt><int2></tt> times to the right
if <tt><int2></tt> is positive, to the left otherwise.
</p>
</div>
<div style="margin-top:0em"> </div><div class=" item_cascade"><div class=" item_leftalign nowrap " ><b>clear</b></div></div>
<div class=" item_text " style="margin-left:2em">
<p style="margin-top:0em; margin-bottom:0em">
Empty the stack. All objects bound to variables are unaffected.
</p>
</div>
</div>
<a name="index"></a>
<h2>INDEX</h2>
<p style="margin-bottom:0" class="asd_par">
This is a list of all <b>mcxi</b>'s primitives, including aliases.
Do 'mcxi /<op> help' to see a short descriptive string, where <op>
is one of the primitives below (remember, strings need a leading slash).
</p>
<p style="margin-bottom:0" class="asd_par">
<b>add</b> <b>addto</b> <b>cdim</b> <b>ch</b> <b>clear</b> <b>copy</b> <b>def</b> <b>dgt</b>
<b>dim</b> <b>div</b> <b>do</b> <b>dup</b> <b>eq</b> <b>exch</b> <b>free</b> <b>gq</b>
<b>grep</b> <b>gt</b> <b>hdm</b> <b>hdp</b> <b>help</b> <b>id</b> <b>ifelse</b> <b>imac</b>
<b>infl</b> <b>info</b> <b>jj</b> <b>lf</b> <b>list</b> <b>lm</b> <b>lq</b> <b>lt</b> <b>max</b>
<b>mdup</b> <b>min</b> <b>mod</b> <b>mul</b> <b>ops</b> <b>pop</b> <b>pow</b> <b>quit</b>
<b>rdim</b> <b>repeat</b> <b>roll</b> <b>st</b> <b>tell</b> <b>tp</b> <b>tut</b> <b>unlink</b>
<b>vars</b> <b>vb</b> <b>vm</b> <b>while</b> <b>wm</b> <b>xpn</b> <b>bye=quit</b> <b>d=def</b>
<b>f=free</b> <b>h=help</b> <b>i=info</b> <b>l=list</b> <b>p=pop</b> <b>g=grep</b>
<b>u=unlink</b> <b>x=exch</b>.
</p>
<a name="author"></a>
<h2>AUTHOR</h2>
<p style="margin-bottom:0" class="asd_par">
Stijn van Dongen.
</p>
<a name="seealso"></a>
<h2>SEE ALSO</h2>
<p style="margin-bottom:0" class="asd_par">
<a class="local sibling" href="mclfamily.html">mclfamily</a> for an overview of all the documentation
</p>
and the utilities in the mcl family.
</body>
</html>
|