Variables in lisp programming

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

which should have a list

(the answer is n)

n is any integer in the list that I want when I type (A 4)

it should display (the answer is 4)

I'm not sure how to do this while thinking about using setq and the list function

But how to build it, it confuses me. I am just a beginner who is trying to learn lisp, any ideas or books that I can read, I will be very grateful.

+4
source share
2 answers
 (defun A (n) (list 'the 'answer 'is n)) (A 4) => (the answer is 4) 
+4
source

Another part of your question is which books to read. Usually people recommend reading " Practical General Lisp ", a book with a friendly and easy to read introduction to Common Lisp. Then there is the article Getting Started at Cliki.net. This should be enough to get started with the language.

0
source

Source: https://habr.com/ru/post/1438472/


All Articles