2. 雙價

先蓋住右方註解,試著自己解釋。
   7-5                       式子 7-5 套用兩個引數來執行減法函數,
2                     但式子 -5 執行取負值只需一個引數。
   -5                         
_5                            

                              採用化學術語原子價的觀念, 稱符號 - 雙價
                              
   7%5                        其有效約束力量由其內容決定。
1.4

   %5                         算數符號 -  雙價特性廣為人知;
0.2                           吾人將谷潩念推廣到其他函數符號。

   3^2
9

   ^2                         指數 (亦即, 2.71828^2)
7.38906

            
   a=: i. 5                   函數 整數整數列
   a
0 1 2 3 4                     數列向量

   a i. 3 1                   函數 索引 or 索引 of
3 1
  
   b=: 'Canada'               兩個單引號括起來代表文指令串
   b i. 'da'
4 1
  
   $ a                        形狀 函數
5

   3 4 $ a                    設定形狀 函數
0 1 2 3                       表格矩陣
4 0 1 2
3 4 0 1
  
   3 4 $ b
Cana
daCa
nada

   %a                         函數作用於數列
_ 1 0.5 0.333333 0.25         符號 _ 代表 無窮大

練習

2.1   Enter following 句子 (and perhaps related 句子 using different引數), observe results,與state what two cases (單邊ic雙邊) of each 函數 do:
   a=: 3 1 4 1 5 9
   b=: 'Canada'
   #a
   1 0 1 0 1 3 # a
   1 0 1 0 1 3 # b
   /: a
   /: b
   a /: a
   a /: b
   b /: a
   b /: b
   c=: 'can''t'
   c
   #c
   c /: c
2.2   Make a summary 表格of 函數 used thus far. n compare it with following 表格(in which a bullet separates 單邊case from雙邊, as in Negate • Subtract):
                                    .               :        
+ • Add • Or
- Negate • Subtract
* • Times • And
% Reciprocal • Divide
^ 指數 • Power • Log
< • Less Than • Lessor Of
> • Greater Than • Greater Of
= • Equals Is (Copula)
i 整數s • 索引 Of    
$ Shape • Reshape
/ 分級•排序
# Number Of Items • Replicate

2.3   Try to fill some of gaps 在表格of Exercise 2.2 by experimenting on computer with appropriate expressions. 例如, enter ^.10 and ^. 2.71828 to determine missing (單邊ic) case of ^. and enter %: 4 and %: -4 and +%: -4 to determine case of % followed by a colon.

However, do not waste time on matters (such as, perhaps, complex numbers or boxed results produced by 單邊 <) that are still beyond your grasp; it may be better to return to m after working through later sections. Note that effects of certain 函數 become evident only when applied to引數or than positive 整數s: try <.1 2 3 4 and <.3.4 5.2 3.6 to determine effect of 單邊 <. .
 
2.4   If b=: 3.4 5.2 3.6 ,n <.b 得到 引數 b rounded down to nearest 整數. Write與test 句子 that rounds 引數 b to nearest 整數.

解答: <.(b+0.5) or <.b+0.5 or <.b+1r2
 
2.5   Enter 2 4 3 $ i. 5 to see an example of a rank 3 陣列 or report (for two years of four quarters of three months each).
 
2.6   Enter ?9 repeatedly與state what 函數 ? does. n enter t=: ?3 5 $ 9 to make a 表格for use in furr experiments.

解答: ? is a (pseudo-) random number generator; ?n produces an 分子 from population i.n


下個前個字彙索引主選單