Comments
NB. This is a comment
Strings
'This is a string.'
'This is a string with ''quotes'' in it.'
Numbers
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
Verbs
%4
3%4
,b
'I';'was';'here'
3 5$'wake read lamp '
Adverbs
1 2 3 */ 4 5 6 7
'%*'(1 3;2 _1)} y
Conjunctions
10&^. 2 3 10 100 200
+`*
+:@*: +/ -:@%:
Examples
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)
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.
)
NB. Implementation of quicksort (tacit programming)
quicksort=: (($:@(<#[), (=#[), $:@(>#[)) ({~ ?@#)) ^: (1<#)