I find the code in an old common lisp book, and try it in lispworks and clozure cl. But both of them cannot run the code. This code is used to remove the pair: (author1 . john).

(setf q '((author1 . john) (author2 . tony) (author3 . fred)))

(setf (assoc 'author1 q) nil)

Thanks for your time

有帮助吗?

解决方案

You can't manipulate the list in-place, but you can get a new list without the specified key in a functional way and reassign the variable:

(setf q (remove 'author1 q :key #'car))

其他提示

The function (SETF ASSOC) is not defined in ANSI Common Lisp and can't be portably defined (it is not allowed by the ANSI CL spec to write a SETF function for a symbol in the CL package).

You need to remove the respective pair some other way.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top