문제

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