Debian Codegraph @

examples/prism-j.html

raw symbols SCIP
1 <h2>Comments</h2>
2 <pre><code>NB. This is a comment</code></pre>
3
4 <h2>Strings</h2>
5 <pre><code>'This is a string.'
6 'This is a string with ''quotes'' in it.'</code></pre>
7
8 <h2>Numbers</h2>
9 <pre><code>2.3e2 2.3e_2 2j3
10 2p1 1p_1
11 1x2 2x1 1x_1
12 2e2j_2e2 2e2j2p1 2ad45 2ar0.785398
13 16b1f 10b23 _10b23 1e2b23 2b111.111</code></pre>
14
15 <h2>Verbs</h2>
16 <pre><code>%4
17 3%4
18 ,b
19 'I';'was';'here'
20 3 5$'wake read lamp '</code></pre>
21
22 <h2>Adverbs</h2>
23 <pre><code>1 2 3 */ 4 5 6 7
24 '%*'(1 3;2 _1)} y</code></pre>
25
26 <h2>Conjunctions</h2>
27 <pre><code>10&^. 2 3 10 100 200
28 +`*
29 +:@*: +/ -:@%:</code></pre>
30
31 <h2>Examples</h2>
32 <pre><code>NB. The following functions E1, E2 and E3
33 NB. interchange two rows of a matrix,
34 NB. multiply a row by a constant,
35 NB. and add a multiple of one row to another:
36
37 E1=: &lt;@] C. [
38 E2=: f`g`[}
39 E3=: F`g`[}
40 f=: {:@] * {.@] { [
41 F=: [: +/ (1:,{:@]) * (}:@] { [)
42 g=: {.@]
43 M=: i. 4 5
44 M;(M E1 1 3);(M E2 1 10);(M E3 1 3 10)</code></pre>
45
46 <pre><code>NB. Implementation of quicksort
47
48 sel=: adverb def 'u # ['
49
50 quicksort=: verb define
51 if. 1 >: #y do. y
52 else.
53 (quicksort y &lt;sel e),(y =sel e),quicksort y >sel e=.y{~?#y
54 end.
55 )</code></pre>
56
57 <pre><code>NB. Implementation of quicksort (tacit programming)
58
59 quicksort=: (($:@(&lt;#[), (=#[), $:@(>#[)) ({~ ?@#)) ^: (1&lt;#)</code></pre>