这是我的口齿不清代码。
(defun f (lst)
(append (subst (last lst) (first lst) (car lst))
(subst (first lst) (last lst) (cdr lst)))
)
(f'(甲、乙、丙、丁)
这个代码的输出是(D B C(一)
该功能运行良好,但由于符号的原因,它没有完成。
我要做没有符号的。
我该怎么修还是有更好的办法?
我很感激你的帮助。
最佳答案
假设你想做某事,你可以:
? (setf lst '(a b c d))
(A B C D)
? lst
(A B C D)
? (rotatef (nth 0 lst) (nth (- (length lst) 1) lst))
;Compiler warnings :
; In an anonymous lambda form at position 0: Undeclared free variable LST (3 references)
NIL
? lst
(D B C A)
关于lisp - Lisp交换列表元素,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42630011/