12. 讀與寫

 f1=: <: 減一 (單邊詞)；小於或等於 f2=: f1&9 小於或等於 9 f3=: f2 *. >:&2 區間檢定， 2 到 9 (包含雙邊) f4=: f3 *. <. = ] 在 2 與 9 之間，且為整數 f5=: f3 +. <. = ] 在 2 與 9 之間，或為整數 g1=: %&1.8 除以 1.8 g2=: g1^:_1 乘以 1.8 g3=: -&32 減 32 g4=: g3^:_1 加 32 g5=: g1@g3 華氏轉攝氏 g6=: g5^:_1 攝氏轉華氏 h1=: >./ 最大值 (單邊詞) h2=: h1-<./ Spread. Try h2 b with parabola: b=:(-&2 * -&3) -:i.12 h3=: h1@]-i.@[*h2@]%<:@[ Grid. Try 10 h3 b h4=: h3 <:/ ] Barchart. Try 10 h4 b h5=: {&' *' @ h4 Barchart. Try 10 h5 b

After entering foregoing定義, enter each 動詞 name alone to display its定義,與learn to interpret resulting displays. To see several forms of display, first enter 9!:3 (2 4 5) .

Cover side of page, and translate 英語定義on back into J.

12.1   se exercises are grouped by topic與organized like section, with programs that are first to be read and n to be rewritten. However, a reader already familiar with a given topic might begin by writing.

A. Properties of numbers

 pn=: >:@i. Positive numbers (e.g. pn 9) rt=: pn |/ pn Remainder表格 dt=: 0&=@rt Divisibility表格 nd=: +/@dt Number of divisors prt=: 2&=@nd Prime test prsel=: prt # pn Prime select N=: >:@pn Numbers greater than 1 rtt=: ,@(N */ N) Ravelled times表格 aprt=: -.@(N e. rtt) Alternative test與selection (primes do not occur 在times 表格for N) apsel=: aprt # N pfac=: q: Prime factors first=: p:@i. First primes

B. 座標幾何

Do experiments on 向量 (or point) p=: 3 4 and triangle represented by 表格 tri=: 3 2\$ 3 4 6 5 7 2

 L=: %:@:(+/)@:*:"1 Length of 向量 (See rank 在dictionary or in Section 20 of Introduction) LR=:L"1 Length of rows in表格 disp=: ] - 1&|. Displacement between rows LS=: LR@disp Lengths of sides of figure sp=: -:@(+/)@LS Semiperimeter (try sp tri) H=: %:@(*/)@(sp,sp-LS) Heron's formula for area det=: -/ . * 行列式 (See dictionary) SA=: det@(,.&0.5) Signed area. Try SA@|. sa=:det@(],.%@!@<:@#) General signed volume; try on tetrahedron tet=:?4 3\$9 as well as on triangle tri .