Domanda

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

È stato utile?

Soluzione

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))

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top