Вы можете использовать mapcar
( ссылка ):
CL-USER> (mapcar #'(lambda (x) (abs x)) (span -10 -1))
(10 9 8 7 6 5 4 3 2 1)
;; can be written also as:
CL-USER> (mapcar (lambda (x) (abs x)) (span -10 -1))
(10 9 8 7 6 5 4 3 2 1)
;; better yet:
CL-USER> (mapcar #'abs (span -10 -1))
(10 9 8 7 6 5 4 3 2 1)
Как цикл:
CL-USER> (loop for x in (span -10 -1) collect (abs x))
(10 9 8 7 6 5 4 3 2 1)
Объединяя это в одной функции:
CL-USER> (defun span (start end &key (step 1) (key #'identity))
(loop for n from start to end by step
collect (funcall key n)))
SPAN
CL-USER> (span -10 -1)
(-10 -9 -8 -7 -6 -5 -4 -3 -2 -1)
CL-USER> (span -10 -1 :key #'abs)
(10 9 8 7 6 5 4 3 2 1)