that is:
"Suppose the function pos+ takes a list and returns a list of each element plus it's position:
> (pos+ '(7 5 1 4))
(7 6 3 7)
Define this function using (a) recursion, (b) iteration, (c) mapcar."
(a) and (b) are straightforward, but (c) I solved following way:
Code: Select all
(defun pos+ (l)
(let ((i -1)) (mapcar #'(lambda (x) (incf i) (+ x i) )
l )))
Moreover, I don't understand why
Code: Select all
(let ((i -1)) (mapcar #'(lambda (x) (+ x i) (incf i) )
l )))