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=: {&' *' @ h4Barchart. 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 .


下個前個字彙索引主選單