lisp编程中的变量

时间:2012-10-08 17:59:49

标签: list functional-programming lisp common-lisp

我正在尝试编写一个函数,让我们说A(n)

应该有一个列表

(the answer is n)

当我输入(A 4)

时,n是我想要的列表中的任何整数

它应显示(the answer is 4)

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

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

2 个答案:

答案 0 :(得分:4)

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

答案 1 :(得分:0)

你问题的另一部分是要阅读的书籍。通常人们建议阅读“Practical Common Lisp”这本书,其中包含对Common Lisp的友好且易于阅读的介绍。然后是Cliki.net上的“Getting Started”文章。这应该足以开始使用该语言。