lisp 变量的作用域
lisp 的变量 作用域是 lexical scoping 的我们看看下面的代码: CL-USER> (setf c 'global-c); in: SETF C; (SETF C 'GLOBAL-C); ==>; (SETQ C 'GLOBAL-C); ; caught WAR...
主要的lisp 表达是例句
(setf x '(a b c))(setf y '(1 2 3))The most important functions on lists are summarized here. The more complicatedones are explained more thoroughly when they are used.( f i r s t X) +a first element o...
lisp 中的 【,@】 与 【·】 以及【‘】 以及【 。,】
我们经常在宏定义中看到这个 ,@body [`] back quator (大键盘 数字键 1 左边的那个键) 以及【‘】 单引号以及【。,body】 (句号后面跟个逗号, cons 返回的那个格式) 示例: (setf...
Common lisp HyperSpec lisp 语法帮助
lisp 里的语法帮助文档, 有是有lispworks 主导组织的, 一大串的 法律条文,我们不关心但是是可以免费使用的,这一点就够了在 emacs + slime 下面怎么中这个东西,总不能每次都打开浏览器登录哦网站搜...
lisp 利器 format 语法示例 控制字符
lisp 里的format 是输出的利器,不亚于c 语言的printf() 我们主要展示 控制字符的行为: 注意 ~s 是输出 “” 的 ~a 是不输出的。~10s ~10a 指定宽带,空格后置 ~10@a ...
lisp 里的循环loop macro
lisp 里的循环很多种尤其是loop 千变万化 ,我也搞不懂,找了一点 示例代码 放这里: Iteration for each element in a list:> (loop for i in '(1 2 3) do (print i))123 Iteration for each cdr of a l...
cons vs list
lisp 里的基本的数据结构 list 而我们常说 list 就是有cons cell 连接起来的那么cons 与list 到底是什么区别呢? list 是 列表, list 的结尾是以 nil 结尾的。cons 是&n...
lisp 里的相等(相同)的比较
common-lisp 里关于相等、相同的比较运算符太多了,怎么用呢? eq eql qual equalp = string-equal char-equal 怎么用呢? 一个大原则: 符号系...
lisp 里的条件判断
if , cond , case and , or 也可以作为判断的一种方式其中case 是的比对是基于eq , 所以业务上应该尽量避免基于字符串的对比。示例: CL-USER> (if (oddp 5 ) &nbs...
lisp 的逻辑计算采用短路策略
common-lisp 的逻辑计算采用的是短路策略or 是采用短路策略CL-USER> (defparameter *is-it-even* nil)*IS-IT-EVEN*CL-USER> *is-it-even*NILCL-USER> (or (oddp 4 ) (setf *is-it-even* t))TCL-USER> *is-it-e...
99-lisp lisp 的99个问题 P11-20
P11 (*) Modified run-length encoding. Modify the result of problem P10 in such a way that if an element has no duplicates it is simply copied into the result list. Only elements with...
99-lisp
lisp 的99个问题 原文的出处已经打不开了,我是从google的cache 里抓下来的,放这里供大家娱乐下 L-99: Ninety-Nine Lisp ProblemsBased on a Prolog problem list by werner.hett@hti.bfh.chWorking wit...
99-lisp lisp 的99个问题 P1-10
这里的问题 来自prolog 的 练习题, 具体出处不明白, 源连接已经打不开了,我是从google 的cache 里抓出来的。有兴趣的同学, 哪来练练手先贴 1-10 第7个问题没有解出来,...
SICP 练习1.6
CL-USER> (defun new-if (predicate then-clause else-clause) (cond (predicate then-clause) (t else-clause)))NEW-IFCL-USER> (new-...
SICP 练习 1.3
CL-USER> (defun sum-of-two(a b c) (cond ((if (>= a b c) ( + a b))) ((if (>= a c b) ( + a c))) &n...
SICP 练习1.1
CL-USER> 1010CL-USER> (+ 5 34) 39CL-USER> (- 9 1) 8CL-USER> (/ 6 2) 3CL-USER> (+ (* 2 4) (- 4 6))6CL-USER> (defvar a 3)ACL-USER> a3CL-USER> (defvar b (+ a 1))BCL-USER> b4CL-USER> (+ a b (* a b))19CL-U...
lisp 开发规范。
c ,c++,python,ruby 。。。。 几乎各个语言都有他们约定俗成的开发规范,lisp 的开发规范是什么样的? lisp 的rfc 文档里是没有说明的,各个实现的文档里也没有,我们就将就下,看看google 是怎么搞得吧!! http...
Lisp Quote 和Backquote分析
原文地址 : http://blog.csdn.net/xiaojianpitt/article/details/7747230对于Lisp初学者来说,最不容易理解的就是Lisp强大的宏。在宏定义中你看到的最多的字符可能是就是引用和反引用。引用和反引用构成了Lisp的基...
lisp 里的 ,@ 反引号 的解释
刚接触lisp 的童鞋,看到宏代码的时候,基本都会遇到这个问题哈。【,@】 【】 中间包括的那俩个符号代表啥意思? 会郁闷很久的。 解释在这里: 反引号 (Backquote)反引号读取宏 (read-macro)使得从模版 (te...
lisp 习题 钱币换算问题
定义一个函数,接受一个整数 cents 并返回四个值,将数字用 25- , 10- , 5- , 1- 来显示,使用最少数量的硬币。(译注: 25- 是 25 美分,以此类推)CL-USER> (defun cents (n) (if (no...