全局变量:

  

>(defparameter *small* 1)
*SMALL*

> (defvar *foo* 5)
*FOO*

 

定义函数:

> (defun guess-my-number()
(ash(+ *small* *big*) -1))
GUESS-MY-NUMBER

lisp函数没有return

计算结果就算return

  ash函数的作用:

    二进制移位 

>(ash 1 1)
2
1 == 1 
向左移位1
10 == 2
> (ash 1 -1)
0

局部变量:

> (let((a 5) (b 6))
(* a b)
)
30

or

]> (
let
(
(a 5)
(b 6)
)
(+ a b)
)
11

lisp代码可以随便写23333

定义本地函数:

> (flet(
(f(n)
(+ n 10)))
(f 5)
)
15

 列表数据:

> '(expt 2 3)
(EXPT 2 3)

lisp中的列表由cons单元组成,cons单元包含两个部分,一个指向值,一个指向下一个cons单元,最后一个cons单元指向nil,nil在lisp里表示空

操作列表:

 

posted on 2019-06-12 17:03  plmls  阅读(157)  评论(0)    收藏  举报