J:一周目(上)

先说下前提概要吧。

首先,如果也要学,大家可以跟着我做一遍(这里我假定大家跟我一样用的也是windows,有不会的留言戳我就好):

0. 安装J的运行环境:先去官网下载,如果系统不是很怪异的(比如server 2003 r2 x64这种),就对应CPU架构来装,如果搞不懂什么是x86,那就默认装x86好了。

0.1 如果你有VPS,还可以跑一个jhs,这样手机上也可以调试可以看(我就是这样的)。jhs有个好处就是,(在默认的profile下)只要你的server不宕机,REPL是单进程的,会保留进度。当然如果你不知道VPS是什么,那就忽略吧。

0.2 因为个人比较推荐用jhs,所以本机文档还是要装的。当然,对于新手来说,jconsole怎么用鬼才知道呢,这时候只能默默地打开jqt,然后安装package(这里推荐安装所有的包,毕竟只是学东西,怎么省事怎么来,毕竟全选安装也不会很占空间)。

J:一周目(上)_第1张图片
从这进到package manager里面去,然后下面那个样子
J:一周目(上)_第2张图片
然后select all再install,等一会就好

0.3 打开jhs,记下这个URL(默认是http://127.0.0.1:65001/jijx):

J:一周目(上)_第3张图片
新手应该是不懂怎么改profile的,所以如果需要让外部网络能访问,还需要设置防火墙或映射端口之类的。也不是很麻烦,比如我就用了 netsh interface portproxy add v4tov4 listenport=2333 connectaddress=127.0.0.1 connectport=65001

1. 然后,打开对应的 J Primer 页面:官网,:本地(默认) 

到这里,我们可以进入正题了。

1.1 首先我们会看到有个目录,这里一周目我们只看这些:

Start here
Why J
Purpose of this book
Your background
How to use this book
Get started
Experiment
Standard profile
Terminology
Alphabet
Word
Sentence
Verb
Noun
Number
Negative number
Primitive
Name
Comment
Error
Ambivalence
Dyad
Monad
Vocabulary
Checkpoint A

和这些

Numeric constant
String
Word formation
Space
Precedence
Parentheses
Order of evaluation
Verb definition
Monad/dyad defined
Script file
Local
Global
Debug global
When =.and =:are alike
When they aren't
Locale
z locale
Script load
Checkpoint B

由于是上篇,所以这里我们只进行到checkpoint A就好。

在 How to use this book (前面的都是基本介绍,大概看看就好)里面有讲到,这本书建议读三遍:

This book is probably best read by reading it three times:

* Skim the whole book. Try some examples, but it is better to just plow on and get the big picture.

* The second time read it carefully and try all the examples.

* The third time try your own examples to clarify your understanding and to increase your comfort with the mechanics of actually using the system (instead of just reading about it and following instructions).

嘛,既然是学,就老实点咯,我是这么想的。

从 Get started 到 Vocabulary 涉及到一些概念和知识点,这里做点记录。

1.2 J 里面有个概念,就是 Terminology(术语),即J里面的术语可能和大多数编程语言有所不同(更接近英语语法范畴内的术语),比如很多语言里面的函数(function)的概念,在J里面其实是动词(verb)。所以下面有必要列一下基本的几种术语及对应关系:

alphabet(字符集),类似传统编程语言里面的字符集和关键字。
word(词),有点类似最小语法单元的概念?
sentence(语句),一行代码。
verb(动词),函数。
noun(名词),类似函数的参数。
number(数字),和传统编程语言一致。
primitive(原语),j里面的系统自带函数(动词)。
name(别名),类似变量名。
comment(注释),形如其名。
error(错误),同上。
monad(单子),单目函数/运算符:f(a)。
dyad(双子),双目函数/运算符:f(a,b)。
ambivalence(结合体),类似erlang里面的同名不同目的函数,或者用OOP里面的多态也勉强可以类比。
adverb(副词),暂时没有涉及。
conjunction(连词),暂时不用涉及。

之所以要标注中文,主要是懒得打英文啊,毕竟还容易拼错。然后关于字符集(ASCII)嘛,其实挺恶心的,不过也方便,J里面的字符传统键盘都能打出来(可能九十年代的老外不太清楚输入法这类东西吧,不然可能APL会是另一种现状了)。

然后归纳一下checkpoint A之前所有涉及到的动词和指令:

+    取共轭(Conjugate)• 加(Plus)
+.  分割复数(Real/Imaginary)• 最大公约数(GCD) 和 或运算(OR)
+:  翻倍(Double)• 异或逻辑(Not-Or)

-    减号:取反(Negate)• 减(Minus)
_    下划线:负号(Negative Sign)• 无穷(Infinity)

CR    jhs里面的一个指令,目前没有过多涉及。

.    目前没有涉及太多,Determinant (?)• Dot Product(点积)
*  目前只演示了双子运算,Signum(?)• 乘(Times)
%  倒数(reciprocal)•除(Divided by)

=. 赋值(Copula(耦合),Is(Local))
NB.   注释,类似js里面 //

1.3 使用jhs的时候,正如 Experiment 里面所讲,可以使用 ctrl+shift+↑来调回上一次输入的语句,省得复制粘贴。

1.4 建议还是按照流程走一遍,多在ijx(就是jhs启动后的那个jijx网页版console)里试试。然后核对一下自己是否满足了checkpoint A的要求:

At this point you should understand:

- how to use the J Dictionary vocabulary
- terms such as word, sentence, noun, verb, ambivalence, dyad, monad

Check your understanding by doing the following exercises:

- look up the definition of the monads+: *: -: %:
- experiment with these new monads

1.5 休息一下,自己回顾总结一遍,然后再继续攻克checkpoint B。

正文

好吧,暂时没有什么要补充的,checkpoint A这一部分比较简单。

你可能感兴趣的:(J:一周目(上))