做网站报价,百度百科创建,263企业邮箱登录入口263,谷歌英文网站优化http://common-lisp.net/project/lispbox/lispbox 集成了Emacs、Slime和CCL。解压后直接运行lispbox.bat即可//(quote x) 返回 x#xff0c;我们简记为 x (quote x)x xx//(atom x) 当 x 是一个原子或者空表时返回原子 t#xff0c;否则返回NIL。在 Common Lisp 中我们…http://common-lisp.net/project/lispbox/ lispbox 集成了Emacs、Slime和CCL。 解压后直接运行lispbox.bat即可 //(quote x) 返回 x我们简记为 x (quote x) x x x //(atom x) 当 x 是一个原子或者空表时返回原子 t否则返回NIL。在 Common Lisp 中我们习惯用原子 t 表示真而用空表 ()和NIL 表示假。 (atom a) t (atom (a b c)) NIL (atom ()) t 一个被引用的表仅仅被视为表 (atom (atom a)) NIL //(eq x y) 当 x 和y 指向相同的对象的时候返回t否则返回NIL值得注意的是在Common Lisp中原子对象在内存中只会有一份拷贝所以(eq a a)返回t (eq a a) t (eq a b) NIL (eq () ()) t (eq (a b c) (a b c)) NIL //(car x) 要求 x 是一个表它返回 x 中的第一个元素 (car (a b)) a //(cdr x) 同样要求 x 是一个表它返回x中除第一个元素之外的所有元素组成的表 (cdr (a b c)) (b c) //(cons x y)期望y的值是一个表并且返回一个新表,它的第一个元素是x的值, 后面跟着y的值的各个元素. (cons a (b c)) (a b c) (cons x y) 返回一个cons cell (x y)如果y不是一个list将会一dotted pair形式展现这个cons cell (cons a b) (a . b) 一个cons cell的第二项如果是另一个cons cell就表示成表的形式 (cons a (cons b c)) (a b . c) 若一个cons cell第二项为空就省略不写 (cons a (cons b ())) (a b) 这样多重的cons cell就构成了表 (cons a (cons b (cons c ()))) (a b c) //函数表示为(lambda (...) e),其中 ...是原子(叫做参数),e是表达式 (lambda (x) (cons x (b))) #Anonymous Function #x2100D5CBFF 函数调用((lambda (...) e) ...) 表达式中第一个元素为函数 ((lambda (x) (cons x (b))) a) (a b) ((lambda (x y) (cons x y)) a (b)) (a b) ((lambda (x y) (cons x (cdr y))) z (a b c)) (z b c) 参数在表达式中不但可以作为自变量也可以作为操作符使用不是cl在环境中报错 ((lambda (f) (f (b c))) (lambda (x) (cons a x))) (a b c) //Emacs快捷键 C-x C-f 创建新文件 C-x C-s 保存工作文件 C-c C-c 重新编译 C-c C-z 切换到REPL //编写hello world函数并保存到文件hello.lisp中。 (defun hello-world() (format t hello, world!)) 加载lisp文件带相对路径 (load ./test/hello.lisp) #Pd:/Program Files/lispbox-0.7/test/hello.lisp 执行函数 (hello-world) hello, world! 加载编译后的文件compile-file先将文件编译成fsl并返回fsl文件名称。 (load (compile-file ./test/hello.lisp)) //列表 (list 1 2 3) (1 2 3) 属性列表property list plist (list :a 1 :b 2 :c 3) (:A 1 :B 2 :C 3) 返回执行符号后的值 (getf (list :a 1 :b 2 :c 3) :a) 1