J:一周目(中)

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 with

Check 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 finished

Check 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 results

Check 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í)器罐,不然容易忘梢为。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市轰坊,隨后出現(xiàn)的幾起案子铸董,更是在濱河造成了極大的恐慌,老刑警劉巖肴沫,帶你破解...
    沈念sama閱讀 218,451評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件袒炉,死亡現(xiàn)場離奇詭異,居然都是意外死亡樊零,警方通過查閱死者的電腦和手機(jī)我磁,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,172評論 3 394
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來驻襟,“玉大人夺艰,你說我怎么就攤上這事〕烈拢” “怎么了郁副?”我有些...
    開封第一講書人閱讀 164,782評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長豌习。 經(jīng)常有香客問我存谎,道長,這世上最難降的妖魔是什么肥隆? 我笑而不...
    開封第一講書人閱讀 58,709評論 1 294
  • 正文 為了忘掉前任既荚,我火速辦了婚禮,結(jié)果婚禮上栋艳,老公的妹妹穿的比我還像新娘恰聘。我一直安慰自己,他們只是感情好吸占,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,733評論 6 392
  • 文/花漫 我一把揭開白布晴叨。 她就那樣靜靜地躺著,像睡著了一般矾屯。 火紅的嫁衣襯著肌膚如雪兼蕊。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,578評論 1 305
  • 那天件蚕,我揣著相機(jī)與錄音孙技,去河邊找鬼惧所。 笑死,一個胖子當(dāng)著我的面吹牛绪杏,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播纽绍,決...
    沈念sama閱讀 40,320評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼蕾久,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了拌夏?” 一聲冷哼從身側(cè)響起僧著,我...
    開封第一講書人閱讀 39,241評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎障簿,沒想到半個月后盹愚,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,686評論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡站故,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,878評論 3 336
  • 正文 我和宋清朗相戀三年皆怕,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片西篓。...
    茶點(diǎn)故事閱讀 39,992評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡愈腾,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出岂津,到底是詐尸還是另有隱情虱黄,我是刑警寧澤,帶...
    沈念sama閱讀 35,715評論 5 346
  • 正文 年R本政府宣布吮成,位于F島的核電站橱乱,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏粱甫。R本人自食惡果不足惜泳叠,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,336評論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望茶宵。 院中可真熱鬧析二,春花似錦、人聲如沸节预。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,912評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽安拟。三九已至蛤吓,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間糠赦,已是汗流浹背会傲。 一陣腳步聲響...
    開封第一講書人閱讀 33,040評論 1 270
  • 我被黑心中介騙來泰國打工锅棕, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人淌山。 一個月前我還...
    沈念sama閱讀 48,173評論 3 370
  • 正文 我出身青樓裸燎,卻偏偏與公主長得像,于是被迫代替她去往敵國和親泼疑。 傳聞我的和親對象是個殘疾皇子德绿,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,947評論 2 355

推薦閱讀更多精彩內(nèi)容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,471評論 5 6
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc閱讀 2,860評論 0 0
  • 按照預(yù)定計劃,前4千米配速在5'30''至6'之間退渗,后1千米在4'30''至5'30''移稳,最后實(shí)在提不起速了,跑表...
    podrunner閱讀 355評論 1 1
  • 她躺著 先是聽見月光碎在院子里 接著她捧不住夜晚 寂寞是大山沉沉的聲音 雪落在街頭 世界如此喧囂
    光白閱讀 359評論 2 6