(defun add-1-all (list)
(mapcar #'1+ '(list))
)
I am trying to pass a list of integers and add 1 to each integer in the list with mapcar, but I keep getting list is defined but never used.
; in: DEFUN ADD-1-ALL
; (DEFUN ADD-1-ALL (LIST) (MAPCAR #'1+ '(LIST)))
; --> SB-IMPL::%DEFUN SB-IMPL::%DEFUN SB-INT:NAMED-LAMBDA
; ==>
; #'(SB-INT:NAMED-LAMBDA ADD-1-ALL
; (LIST)
; (BLOCK ADD-1-ALL (MAPCAR #'1+ '(LIST))))
;
; caught STYLE-WARNING:
; The variable LIST is defined but never used.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
Since you're quoting
(list), this is a list containing the literal symbollist, it not the value of the variable. That's why you get a warning about an unused variable.And when you run it, you'll get an error because
1+requires its argument to be a number, not the symbollist.The second argument to
mapcarshould be the value of the list itself, so just used the variable directly.