相关疑难解决方法(0)

Strange Lisp Quoting场景 - Graham的On Lisp,第37页

我正在通过格雷厄姆的书"On Lisp"工作,并且无法理解第37页的以下示例:

If we de?ne exclaim so that its return value
incorporates a quoted list,

(defun exclaim (expression)
  (append expression ’(oh my)))

>  (exclaim ’(lions and tigers and bears))
(LIONS AND TIGERS AND BEARS OH MY)
> (nconc * ’(goodness))
(LIONS AND TIGERS AND BEARS OH MY GOODNESS)

could alter the list within the function:

> (exclaim ’(fixnums and bignums and floats))
(FIXNUMS AND BIGNUMS AND FLOATS OH MY GOODNESS)

To make exclaim proof against such problems, it should be written:
(defun exclaim …

lisp common-lisp quoting literals on-lisp

13
推荐指数
3
解决办法
490
查看次数

意外的数据持久性

我有一个七个整数的列表,最初都是0,我们称之为"数据".在运行程序的过程中,我想定期将其中一个整数的值递增一.在程序结束时我打印数据.一切都很好,除了在程序的每次连续运行中,上次运行的所有数据值都被添加到此运行的所有数据值中.我只想要来自此次运行的数据值.无论数据是类的方法中的局部变量,类的方法调用的单独函数中的局部变量,还是类的槽,都会发生这种意外行为.无论我是通过incf还是(setf value(1+ value))递增数据的各个值,都会发生这种情况.当我重新加载程序时,数据重置为全零,但是当我再次运行程序时,数据会再次添加所有的最后一次运行' s数据到此运行的数据.当我增加其中一个数据值时,我使用函数nth,其中index是另一个对象槽的值.什么可能导致我的"数据"列表的值不受欢迎的持久性?

lisp scheme common-lisp literals

7
推荐指数
1
解决办法
437
查看次数

标签 统计

common-lisp ×2

lisp ×2

literals ×2

on-lisp ×1

quoting ×1

scheme ×1