本帖最后由 自贡黄明儒 于 2024-8-9 09:10 编辑
- (setq x 2)
- (setq y 3)
- (defun swap (a b)
- (setq temp (eval a))
- (set a (eval b))
- (set b temp)
- )
(swap 'x 'y);===>x=3 y=2
by 和尚777
- (setq a 2)
- (setq b 3)
- (defun swap (a b)
- (setq temp (eval a))
- (set a (eval b))
- (set b temp)
- )
(swap 'a 'b);===>a=2 b=3
总结:二个值交换,不自定义函数,直接交换 by 老迈
- (mapcar (function set) (list (quote a) (quote b)) (list b a))
复制代码
|