I was working on a tutorial on general lisp, and I just got acquainted with incf and dolist , I wanted to know if I understood correctly how dolist functions perform the inc-list function, which will increase each list item by one:
(defvar a-list (list 1 2 3))
(inc-list a-list) => (2 3 4)
This is how I defined inc-list
(defun inc-list (list) (progn (dolist (element list) (incf element)) list))
This does not work. when I try (inc-list a-list) , I return (1 2 3) and a-list => (1 2 3) . This would not bother me if it were not for the fact that:
(incf (car a-list)) (incf (cadr a-list)) (incf (caddr a-list))
gives me a-list => (2 3 4) . Is there any secret to what element means?
source share