NB. 一周目本來應(yīng)該在7日內(nèi)結(jié)束的淘捡,無奈這周事情有點(diǎn)多,只好延后一天了 = =?
之前寫完一周目上篇的時候也順便往后開了下,其實(shí) checkPoint ABC 都不是很難的樣子片效。于是原本說是到B就可以的红伦,現(xiàn)在有點(diǎn)貪心不足想往后趕到E。不過也就需要花更多的時間了...
另外這里其實(shí)有個問題淀衣,就是 J Primer 是按照 J 60x寫的昙读,現(xiàn)在已經(jīng) J80x了,所以有些操作會有些對不上膨桥。不過影響不大蛮浑,下文也會提供些折中的辦法。
先進(jìn)入正題只嚣,看下 checkpoint B沮稚,不對,先回顧下上篇:
- 簡單說册舞,J跟常規(guī)編程語言的差別主要體現(xiàn)在:沒有(嚴(yán)格的)運(yùn)算優(yōu)先級蕴掏,(從右往左)順序執(zhí)行
- 然后,checkPoint A要求搞懂的幾個動詞:+: ? ?*: ? ?-: ? ?%:? ?NB. 好吧调鲸,老實(shí)說上篇我把這個環(huán)節(jié)忽略了...不過第一遍的話盛杰,也沒啥關(guān)系啦
然后看下B部分的目錄:
Numeric constant? ? 這一節(jié)引入了列表,和傳統(tǒng)編程語言沒啥差別藐石,只是少了方括號
String? ? 只能用單引號框字符串即供,如果要轉(zhuǎn)義字符串內(nèi)的單引號,敲兩個就好了贯钩。
Word formation? ? 這招后面應(yīng)該比較管用募狂,用 ;: 來分割語句,初學(xué)必備(記得用單引號框起來
Space? ? 講了什么時候該有空格什么時候可以省略角雷,其實(shí)初學(xué)的話祸穷,全部打上比較好看清吧
Precedence? ? 講優(yōu)先級的,原話:Remember: there is no verb precedence.
Parentheses? ? 括號的用法和常規(guī)語音類似
Order of evaluation? ? 求值順序:no verb precedence and right-to-left evaluation.
Verb definition? ? 講動詞(函數(shù))定義的方法勺三,第一感覺會比較奇葩
Monad/dyad defined? ? 同上雷滚,(不完全)詳解單子和雙子的定義方法
Script file? ? 教你怎么寫文件這里開始容易出現(xiàn)版本上的差異
Local? ? 解釋局部變量 =.
Global? ? 解釋全局變量 =:
Debug global? ? 講了一個很簡單粗暴的使用全局變量的調(diào)試技巧
When =.and =:are alike? ? 簡單解釋了局部和全局的差別
When they aren't? ? 同理。
Locale? ? A locale is a set(集合) of global names.
z locale? ? The z locale is the?parent locale?of all other locales.
Script load? ? 如何調(diào)用腳本
Checkpoint B
At this point you should understand:
- a text file that is a source of sentences is called a script file
- a script file defines global names
- how to create a new temporary script file
- how to save a temporary script file as a permanent file
- how to run a script file to execute its sentences
- how to define a verb in a script file
- how to define the monadic and dyadic cases of a verb
- the difference between=.and=:
- the difference between local and global
- that a locale is a set of global names
- that there can be more than one locale
- that the base locale is the one you normally work withCheck your understanding by doing the following exercises:
- create a new temporary script file
- in the script define square as a monad that uses *: to square its argument
- save the script in the user directory with the name square.ijs
- run the script and test the verb square
- close J, restart, use Run|File to run user\square.ijs and test it
其實(shí)checkpointB的內(nèi)容也不少吗坚,主要就是明白怎么寫腳本祈远,定義動詞,以及l(fā)ocale的用法商源。
然后是下一部分:
Debug - step through? ? 步進(jìn)調(diào)試 dbss, dbr, dbrun
Debug - an error? ? dbjump
Comparative? ? 比較符 =? ? <? ? <:? ? >? ? >:
Control structure? ? 控制結(jié)構(gòu)? if.? / ?do. ?/ ?else. ?/ ?elseif.? ? try.? ? while.? / ?whilst.? ? for.? / ?for_i.? ? select.? / case. ?/ ?fcase. ? ?end.
Checkpoint C
At this point you should understand:
- that load 'debug' ?loads debug utilities
- the general idea of verb debugging
- how control words create control structures by grouping sentences into blocks
- what the T block test result is
- how the test result determines which B block to execute
- how the test result determines when control structure execution is finishedCheck your understanding by doing the following exercises:
- debug step through your convert verb
- create a temporary script file and define a verb calledconvthat is similar toconvert, but insists on a 'f' argument to do the conversion to Fahrenheit and gives a string result indicating there was an error if the left argument is neither 'c' nor 'f'. Hint: use the control structure sketched out here:if. x = 'c' do. ...
? ? elseif. x = 'f' do. ...
? ? elseif. 1 do. 'left arg not c or f'
end.or try aselect.structure.
- create a temporary script file and define a dyad called plus that adds its left argument to its right. But, if there is an error, it should give a string result. Hints: use dyad :0; 4 plus 9should return 13;'a' plus 9should return your error string (perhaps,'there was an error'); use atry.control structure to catch the error and give the string result.
cpC的內(nèi)容也不難懂车份,暫時沒啥要總結(jié)的,回去做下練習(xí)題就好牡彻。然后是cpD:
Adding lists? 基本列表操作? {???? ,???? #????
J way of adding lists??? 列表操作的正確打開方式(APL風(fēng)格)
A few more primitives??? 引入更多運(yùn)算? i.??? $???? ????? ^???? o.?
Plot? 這個很方便扫沼,jhs開出來的網(wǎng)頁版jijx也可以用出爹。三角函數(shù)可能有點(diǎn)不好懂
Plot locale? 以load 'plot'為例帶你回顧下前面的locale
Print precision??? 輸出精度控制
Inexact numbers?? 繼續(xù)浮點(diǎn)數(shù)精度的問題
Tolerance???? 關(guān)于精度誤差的容錯
Checkpoint D
At this point you should understand:
?- primitives work with lists
?- your own verbs work with lists
?- how to use several new verbs
?- how to use the plot facility
?- comparatives such as = that give numeric 0 and 1 resultsCheck your understanding by doing the following exercises:
?- look up the J Dictionary definitions of the integers, shape, roll, power, and circle verbs; in most cases only a part of their capabilities have been introduced, so you will have to read the definitions carefully to be able to ignore the parts not yet relevant, and to pick out the parts that are
?- experiment with the new primitives
感覺E部分比較多,可以當(dāng)作回顧性內(nèi)容缎除,所以把原定一篇搞定的下篇分成中下兩篇了严就。
這篇知識點(diǎn)不少,需要多加練習(xí)器罐,不然容易忘梢为。