]b=: i.7 0 1 2 3 4 5 6 b^2 平方 0 1 4 9 16 25 36 b^3 立方 0 1 8 27 64 125 216 b^0.5 平方根 0 1 1.41421 1.73205 2 2.23607 2.44949聯結連接詞 & 可以用來聯結某一雙邊詞的某一引數,以產生新的相關動詞。例如:
square=: ^&2 平方 (指數 2) square b 0 1 4 9 16 25 36 (sqrt=: ^&0.5) b 開根號函數 0 1 1.41421 1.73205 2 2.23607 2.44949左引數也可以做類似的聯結:
Log=: 10&^. 以10為底的對數 Log 2 4 6 8 10 100 1000 0.30103 0.60206 0.778151 0.90309 1 2 3如此定義的動詞 當然也可以用在三叉定義。例如:
in29=: 2&< *. <&9 區間檢驗 in29 0 1 2 5 8 13 21 0 0 0 1 1 0 0 IN29=: in29 # ] 區間選擇 IN29 0 1 2 5 8 13 21 5 8 LOE=: <+.= 5 LOE 3 4 5 6 7 0 0 1 1 1 整數test=: <. = ] 單邊詞 <. 為下整數 整數test 0 0.5 1 1.5 2 2.5 3 1 0 1 0 1 0 1 int=: 整數test int (i.13)%3 1 0 0 1 0 0 1 0 0 1 0 0 1
練習
7.1 | 動詞 # is used雙邊ally 在
program IN29 .Enter expressions such
as(j=: 3 0 4 0 1) # i.5 to determine behaviour
of #,and state result of #j#i.5 .
(Also try 1j1#i.5 .) 解答: +/j |
7.2 | Cover answers on 右與apply following programs
to lists to determine (and state in 英語) purpose of each: test1=: >&10 *. <&100 Test if in 10 to 100 int=: ] = < Test if 整數 test2=: int *. test1 Test if 整數與in 10 to 100 test3=: int +. test1 Test if 整數 or in 10 to 100 sel=: test2 # ] Select 整數s in 10 to 100 |
7.3 | Cover program 定義on 左of
preceding exercise,與make new programs for stated effects. |
7.4 | Review use of fix 副詞 in 練習 6.4-5,與
experiment with its use on programs of Exercise 7.2. |