-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgap.html
553 lines (550 loc) · 19.8 KB
/
gap.html
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
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang xml:lang>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>Codebraid with GAP (Groups, Algorithms, Programming - a System for Computational Discrete Algebra)</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; }
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.at { color: #7d9029; }
code span.bn { color: #40a070; }
code span.bu { color: #008000; }
code span.cf { color: #007020; font-weight: bold; }
code span.ch { color: #4070a0; }
code span.cn { color: #880000; }
code span.co { color: #60a0b0; font-style: italic; }
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.do { color: #ba2121; font-style: italic; }
code span.dt { color: #902000; }
code span.dv { color: #40a070; }
code span.er { color: #ff0000; font-weight: bold; }
code span.ex { }
code span.fl { color: #40a070; }
code span.fu { color: #06287e; }
code span.im { color: #008000; font-weight: bold; }
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.kw { color: #007020; font-weight: bold; }
code span.op { color: #666666; }
code span.ot { color: #007020; }
code span.pp { color: #bc7a00; }
code span.sc { color: #4070a0; }
code span.ss { color: #bb6688; }
code span.st { color: #4070a0; }
code span.va { color: #19177c; }
code span.vs { color: #4070a0; }
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; }
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<style type="text/css">body {
display: block;
text-align: left;
max-width: 40rem;
padding-left: 0.5rem;
padding-right: 0.5rem;
margin: auto;
}
pre.numberSource a.sourceLine {
position: relative;
left: -3em;
}
pre.numberSource a.sourceLine::before{
content: attr(title);
position: relative;
left: -1em;
text-align: right;
vertical-align: baseline;
border: none;
pointer-events: all;
display: inline-block;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
padding: 0 4px;
width: 3em;
color: #aaaaaa;
}
pre.numberSource {
margin-left: 2em;
border-left: 1px solid #aaaaaa;
padding-left: 4px;
}
div.exampleMarkup:before{
content: "Markdown";
font-family: monospace;
display: block;
height: 2em;
font-size: 150%;
}
div.exampleMarkup {
padding-top: 0.5em;
padding-left: 0.5em;
padding-right: 0.5em;
margin-top: 2em;
margin-bottom: 1em;
background-color: honeydew;
border-style: solid;
border-width: 1px;
border-color: limegreen;
border-radius: 0.2em;
}
div.exampleOutput:before{
content: "Output";
font-family: monospace;
display: block;
font-size: 150%;
}
div.exampleOutput {
color: black;
padding-top: 0.5em;
padding-left: 0.5em;
padding-right: 0.5em;
margin-top: 1em;
margin-bottom: 2em;
background-color: whitesmoke;
border-style: solid;
border-width: 1px;
border-color: lightgray;
border-radius: 0.2em;
}
div.sourceCode {
padding: 0.5em;
background-color: aliceblue;
border-style: solid;
border-width: 1px;
border-color: lightskyblue;
border-radius: 0.2em;
}
div.exampleOutput div.sourceCode:before{
content: "code";
font-family: monospace;
display: block;
height: 2em;
font-weight: bold;
font-size: 120%;
}
pre.stdout:before{
content: "stdout";
display: block;
height: 2em;
font-weight: bold;
font-size: 120%;
}
pre.stdout {
color: black;
padding: 0.5em;
background-color: azure;
border-style: solid;
border-width: 1px;
border-color: turquoise;
border-radius: 0.2em;
padding-left: 0.5em;
}
code.stdout {
color: black;
background-color: azure;
border-style: solid;
border-width: 1px;
border-color: turquoise;
}
pre.stderr:before{
content: "stderr";
display: block;
height: 2em;
font-weight: bold;
font-size: 120%;
}
pre.stderr {
color: red;
padding: 0.5em;
background-color: lavenderblush;
border-style: solid;
border-width: 1px;
border-color: pink;
border-radius: 0.2em;
padding-left: 0.5em;
}
code.stderr {
color: red;
background-color: lavenderblush;
border-style: solid;
border-width: 1px;
border-color: pink;
}
pre.error:before{
content: "Error";
display: block;
height: 2em;
font-weight: bold;
font-size: 120%;
}
pre.error {
color: red;
padding: 0.5em;
background-color: lavenderblush;
border-style: solid;
border-width: 1px;
border-color: pink;
border-radius: 0.2em;
padding-left: 0.5em;
}
code.error {
color: red;
background-color: lavenderblush;
border-style: solid;
border-width: 1px;
border-color: pink;
}
</style>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
<![endif]-->
</head>
<body>
<header id="title-block-header">
<h1 class="title">Codebraid with GAP (Groups, Algorithms, Programming -
a System for Computational Discrete Algebra)</h1>
</header>
<h2 id="inline-code">Inline code</h2>
<h3 id="run">Run</h3>
<p>Inline code with <code>.cb-run</code> gives raw stdout.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>`Print(1 + 2);`{.gap .cb-run session=firsttest}</code></pre>
</div>
<div class="exampleOutput">
<p>3</p>
</div>
</div>
<h3 id="expression-and-inline-notebook">Expression and inline
notebook</h3>
<p>Inline code with <code>.cb-expr</code> evaluates an expression and
then inserts the raw output into the document, where it is interpreted
as Markdown. Inline code with <code>.cb-nb</code> (<code>nb</code> is
short for <code>notebook</code>) is similar, except output is shown
verbatim. Notice that since these are expressions, a trailing semicolon
must not be used.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>`StringFormatted("*{}*", Sum([1..10]))`{.gap .cb-expr}</code></pre>
</div>
<div class="exampleOutput">
<p><em>55</em></p>
</div>
</div>
<div class="example">
<div class="exampleMarkup">
<pre><code>`StringFormatted("*{}*", Sum([1..10]))`{.gap .cb-nb}</code></pre>
</div>
<div class="exampleOutput">
<p><code class="expr">*55*</code></p>
</div>
</div>
<h3 id="stderr">Stderr</h3>
<p>In the event of an error, inline code automatically shows stderr by
default. This code is executed in its own session,
<code>inline_error</code>, so that it does not impact other
examples.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>`1 + "a"`{.gap .cb-run session=inline_error}</code></pre>
</div>
<div class="exampleOutput">
<p><code class="stderr error">Error, no method found! For debugging hints type ?Recovery from NoMethodFound Error, no 1st choice method found for `CallFuncList' on 2 arguments</code></p>
</div>
</div>
<h3 id="source-errors">Source errors</h3>
<p>A message is also displayed for errors in the Markdown source. This
usually includes the name of the document source and the approximate
line number.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>`Print(1 + 2);`{.gp .cb-run session=inline_source_error}</code></pre>
</div>
<div class="exampleOutput">
<p><code class="error sysConfigError">SYS CONFIG ERROR in "gap.cbmd" near line 43: Language definition for "gp" does not exist</code></p>
</div>
</div>
<h3 id="code">Code</h3>
<p>Inline code with <code>.cb-code</code> simply displays the code.
Nothing is executed.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>`Print("Hello from GAP!");`{.gap .cb-code}</code></pre>
</div>
<div class="exampleOutput">
<p><code class="gap">Print("Hello from GAP!");</code></p>
</div>
</div>
<p>The output is identical to that of</p>
<pre><code>`Print("Hello from GAP!");`{.gap}</code></pre>
<p>so <code>.cb-code</code> is only really useful when it is combined
with other Codebraid features. For example, it is possible to give code
with <code>.cb-code</code> a <code>name</code>, and then copy it by
<code>name</code> into a separate location where it is executed. See <a href="#copying">Copying code and output</a>.</p>
<h2 id="block-code">Block code</h2>
<h3 id="run-1">Run</h3>
<p>Code blocks with <code>.cb-run</code> give raw stdout. There is
continuity between code blocks so long as they are in the same session;
variables persist.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-run session=hello}
x := "Hello from *GAP!*";
```</code></pre>
</div>
</div>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-run session=hello}
Print(x);
```</code></pre>
</div>
<div class="exampleOutput">
<p>Hello from <em>GAP!</em></p>
</div>
</div>
<h3 id="stderr-1">Stderr</h3>
<p>Code blocks show stderr automatically by default.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-nb session=block_error}
x := 12;
y := x + "x";
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb11" data-startFrom="1"><pre class="sourceCode numberSource gap numberLines"><code class="sourceCode"><span id="cb11-1"><a href="#cb11-1"></a>x := 12;</span>
<span id="cb11-2"><a href="#cb11-2"></a>y := x + "x";</span></code></pre></div>
<pre class="stderr error"><code>Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `+' on 2 arguments</code></pre>
</div>
</div>
<h3 id="source-errors-1">Source errors</h3>
<p>A message is also displayed for errors in the Markdown source. This
usually includes the name of the document source and the approximate
line number.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-ruuun session=block_source_error}
print(1 + 2);
```</code></pre>
</div>
<div class="exampleOutput">
<pre class="error sourceError"><code>SOURCE ERROR in "gap.cbmd" near line 96:
Unknown or unsupported Codebraid command "cb-ruuun"
SOURCE ERROR in "gap.cbmd" near line 96:
Missing valid Codebraid command</code></pre>
</div>
</div>
<h3 id="code-1">Code</h3>
<p>Code blocks with <code>.cb-code</code> simply display the code.
Nothing is executed.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-code}
Print("Hello from GAP!");
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb16" data-startFrom="1"><pre class="sourceCode numberSource gap numberLines"><code class="sourceCode"><span id="cb16-1"><a href="#cb16-1"></a>Print("Hello from GAP!");</span></code></pre></div>
</div>
</div>
<p>The output is essentially identical to that of a normal code block;
the only differences are some default display options, like line
numbering. Thus <code>.cb-code</code> is primarily useful when it is
combined with other Codebraid features. For example, it is possible to
give code with <code>.cb-code</code> a <code>name</code>, and then copy
it by <code>name</code> into a separate location where it is executed.
See <a href="#copying">Copying code and output</a>.</p>
<h2 id="other-options">Other options</h2>
<p>By default, stdout and stderr are only shown if they are non-empty.
In some situations, it may be useful to represent empty output visually
as confirmation that there indeed was none.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-run show=code+stdout+stderr:verbatim_or_empty}
x := 1 + 2;;
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb18" data-startFrom="1"><pre class="sourceCode numberSource gap numberLines"><code class="sourceCode"><span id="cb18-1"><a href="#cb18-1"></a>x := 1 + 2;;</span></code></pre></div>
<pre class="stderr"><code> </code></pre>
</div>
</div>
<p>It is also possible to selectively hide output from a code chunk.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-nb hide=stdout}
Print(x);
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb21" data-startFrom="2"><pre class="sourceCode numberSource gap numberLines"><code class="sourceCode" style="counter-reset: source-line 1;"><span id="cb21-2"><a href="#cb21-2"></a>Print(x);</span></code></pre></div>
</div>
</div>
<p><code>hide</code> takes any combination of <code>code</code>,
<code>stderr</code>, and <code>stdout</code>, or simply
<code>all</code>.</p>
<h2 id="advanced">Advanced features</h2>
<h3 id="copying">Copying code and output</h3>
<p>Code chunks can be named using the <code>name</code> keyword, which
takes an identifier-style name. Then the <code>copy</code> keyword can
be used in other code chunks to copy a named chunk or a combination of
named chunks. When <code>copy</code> is used with <code>cb-run</code>,
<code>cb-expr</code>, or <code>cb-nb</code>, the code is copied and then
executed as if it had been entered directly. When <code>copy</code> is
used with <code>cb-code</code>, the code is copied and displayed, but
nothing is executed. When <code>copy</code> is used with the special
command <code>cb-paste</code>, both the code and output are copied but
nothing is executed. This is useful in executing code and then showing
snippets of the code and/or output in different parts of a document.</p>
<p><code>copy</code> works with named code chunks anywhere in a
document; a named code chunk does not have to appear in a document
before the location where it is copied. A code chunk that copies another
code chunk can itself have a <code>name</code>, and then itself be
copied.</p>
<p>The next two code chunks are named.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-run name=part1 session=copy_source}
rnums := List([1..10], x -> Random([1..x]));;
```</code></pre>
</div>
</div>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-run name=part2 session=copy_source}
PrintFormatted("Random numbers: {}", rnums);
```</code></pre>
</div>
<div class="exampleOutput">
<p>Random numbers: [ 1, 2, 1, 3, 3, 2, 3, 3, 5, 5 ]</p>
</div>
</div>
<p>Now the code and output of the previous two code chunks are copied
and combined. Because the content for this code block is copied from
other code chunks, the code block itself should be empty, or may
alternately contain a space or underscore as a placeholder.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-paste copy=part1+part2 show=code+stdout}
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb25" data-startFrom="1"><pre class="sourceCode numberSource gap numberLines"><code class="sourceCode"><span id="cb25-1"><a href="#cb25-1"></a>rnums := List([1..10], x -> Random([1..x]));;</span>
<span id="cb25-2"><a href="#cb25-2"></a>PrintFormatted("Random numbers: {}", rnums);</span></code></pre></div>
<pre class="stdout"><code>Random numbers: [ 1, 2, 1, 3, 3, 2, 3, 3, 5, 5 ]</code></pre>
</div>
</div>
<p>It would also be possible to copy and re-execute the code.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-run copy=part1+part2 session=copied show=code+stdout:raw}
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb28" data-startFrom="1"><pre class="sourceCode numberSource gap numberLines"><code class="sourceCode"><span id="cb28-1"><a href="#cb28-1"></a>rnums := List([1..10], x -> Random([1..x]));;</span>
<span id="cb28-2"><a href="#cb28-2"></a>PrintFormatted("Random numbers: {}", rnums);</span></code></pre></div>
<p>Random numbers: [ 1, 2, 1, 3, 3, 2, 3, 3, 5, 5 ]</p>
</div>
</div>
<p>Another option is to display code, and then copy and execute it
later.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-code name=hello}
Print("Hello from GAP!");
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb30" data-startFrom="1"><pre class="sourceCode numberSource gap numberLines"><code class="sourceCode"><span id="cb30-1"><a href="#cb30-1"></a>Print("Hello from GAP!");</span></code></pre></div>
</div>
</div>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.gap .cb-nb copy=hello}
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb32" data-startFrom="3"><pre class="sourceCode numberSource gap numberLines"><code class="sourceCode" style="counter-reset: source-line 2;"><span id="cb32-3"><a href="#cb32-3"></a>Print("Hello from GAP!");</span></code></pre></div>
<pre class="stdout"><code>Hello from GAP!</code></pre>
</div>
</div>
<h3 id="including-external-files">Including external files</h3>
<p>External files can be included for display or execution using
<code>include_file</code>. The default encoding is UTF-8; other
encodings can be selected with <code>include_encoding</code>. Instead of
including the entire file, it is possible to include only a selected
range of lines with <code>include_lines</code>. It is also possible to
include part of a file that matches a regular expression with
<code>include_regex</code>, as shown in the example. Other options for
controlling what is included based on starting or ending literal strings
or regular expressions can be found in the documentation.</p>
<div class="example">
<div class="exampleMarkup">
<pre><code>```{.html .cb-code include_file=gap.html include_regex="<header.*?/header>"}
```</code></pre>
</div>
<div class="exampleOutput">
<div class="sourceCode" id="cb35" data-startFrom="1"><pre class="sourceCode numberSource html numberLines"><code class="sourceCode html"><span id="cb35-1"><a href="#cb35-1"></a><span class="kw"><header</span> <span class="er">id</span><span class="ot">=</span><span class="st">"title-block-header"</span><span class="kw">></span></span>
<span id="cb35-2"><a href="#cb35-2"></a><span class="kw"><h1</span> <span class="er">class</span><span class="ot">=</span><span class="st">"title"</span><span class="kw">></span>Codebraid with GAP (Groups, Algorithms, Programming -</span>
<span id="cb35-3"><a href="#cb35-3"></a>a System for Computational Discrete Algebra)<span class="kw"></h1></span></span>
<span id="cb35-4"><a href="#cb35-4"></a><span class="kw"></header></span></span></code></pre></div>
</div>
</div>
<p>When <code>include_file</code> is used with <code>cb-code</code>, the
included code is simply displayed. When <code>include_file</code> is
used with <code>cb-run</code> or another command that executes code, the
included code is executed just as if it had been entered directly.</p>
</body>
</html>