lisp编程中的变量(variables in lisp programming)

我想写一个函数让我说A(n)

应该有一个列表

(the answer is n)

当我输入时,n是我想要的列表中的任何整数(A 4)

它应该显示(the answer is 4)

我不确定如何考虑使用setq and the list function

但如何构建它让我感到困惑我只是一个新手试图学习lisp,我能读到的任何想法或书籍我将非常感激。

I am trying to write a function lets say A(n)

which is supposed to have a list

(the answer is n)

n being any integer in the list I want when i type (A 4)

it should display (the answer is 4)

I am not sure how to go about it thinking of using setq and the list function

But how to construct it its confusing me I'm just a newbie trying to learn lisp, any ideas or books I can read I will greatly appreciate.

最满意答案

(defun A (n) (list 'the 'answer 'is n)) (A 4) => (the answer is 4) (defun A (n) (list 'the 'answer 'is n)) (A 4) => (the answer is 4)

更多推荐