I wonder why in the following code, d is not being consed into x.
Any hints are much appreciated.
(defun it (x)
(setq f '(a b c))
(dolist (d f)
(cons d x))
(print x))
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t know a lot about LISP, but here’s a few things I think I know that might help you:
(cons d x) doesn’t put d “into” x; it creates a new value that consists of d, followed by the contents of x. If x is a list, then (cons d x) will also be a list.
(cons d x) doesn’t change anything; it creates a value, but if you don’t capture that value, it gets discarded again. In particular, that expression doesn’t change x.