문제

I'm taking a list name as input with a single quote ('), but after doing a few operations, I want to actually evaluate it instead of treat it as an atom.

So for example, just for simplicity sake, I have the following list:

(setf LT '(A B C))

I have a function called SEP. To run the function, I must run it as (SEP 'LT). So as you can see, LISP will interpret LT as an atom instead of evaluate it as a list, which is not what I want.

So essentially, I want (SEP 'LT) to really become (SEP '(A B C)) somehow.

The input format can't be changed. Any help would be appreciated. Thanks!

도움이 되었습니까?

해결책

If LT is a top-level variable, defined with defvar, then you can get its value with symbol-value as such:

* (symbol-value 'lt)
(A B C)

* (defun sep (name)
    (assert (symbolp name))
    (let ((value (symbol-value name)))
      ...
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top