Hash :
bf551967
Author :
Date :
2017-02-08T23:25:12
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
<h1>J</h1>
<p>To use this language, use the class "language-j".</p>
<h2>Comments</h2>
<pre><code>NB. This is a comment</code></pre>
<h2>Strings</h2>
<pre><code>'This is a string.'
'This is a string with ''quotes'' in it.'</code></pre>
<h2>Numbers</h2>
<pre><code>2.3e2 2.3e_2 2j3
2p1 1p_1
1x2 2x1 1x_1
2e2j_2e2 2e2j2p1 2ad45 2ar0.785398
16b1f 10b23 _10b23 1e2b23 2b111.111</code></pre>
<h2>Verbs</h2>
<pre><code>%4
3%4
,b
'I';'was';'here'
3 5$'wake read lamp '</code></pre>
<h2>Adverbs</h2>
<pre><code>1 2 3 */ 4 5 6 7
'%*'(1 3;2 _1)} y</code></pre>
<h2>Conjunctions</h2>
<pre><code>10&^. 2 3 10 100 200
+`*
+:@*: +/ -:@%:</code></pre>
<h2>Examples</h2>
<pre><code>NB. The following functions E1, E2 and E3
NB. interchange two rows of a matrix,
NB. multiply a row by a constant,
NB. and add a multiple of one row to another:
E1=: <@] C. [
E2=: f`g`[}
E3=: F`g`[}
f=: {:@] * {.@] { [
F=: [: +/ (1:,{:@]) * (}:@] { [)
g=: {.@]
M=: i. 4 5
M;(M E1 1 3);(M E2 1 10);(M E3 1 3 10)</code></pre>
<pre><code>NB. Implementation of quicksort
sel=: adverb def 'u # ['
quicksort=: verb define
if. 1 >: #y do. y
else.
(quicksort y <sel e),(y =sel e),quicksort y >sel e=.y{~?#y
end.
)</code></pre>
<pre><code>NB. Implementation of quicksort (tacit programming)
quicksort=: (($:@(<#[), (=#[), $:@(>#[)) ({~ ?@#)) ^: (1<#)</code></pre>