先不说楼主的函数是否有意义。我来就事论事。想要改变值的引用方式,AutoLISP中没有直接的办法,只能使用引用符号的方式来模拟指针类的引用。因此,达到你要求的效果,需要自己改写Mapcar函数。首先举个改变参数值的例子,比如,类似于C语言中的i++, ++i, 你可以通过对符号的引用改变符号的值:
-
- (defun ++ (x)
- (set x (1+ (eval x)))
- );;; test ++(setq a 3)
- (++ 'a)
- (++ 'a)
- (princ a)
符合你要求的Mapcar函数只能自己改写: -
- (defun mapcar2 (func lstsym / lst rt i)
- (setq i 0)
- (while ((("AAA,ABC,CDF" "BBB") ("CCC" "DDD"))
- ;;;
- (defun test (lst / nlst)
- (mapcar '(lambda(x)(setq xx (cadr x))
- (if (not(apply 'or (mapcar '(lambda(y)(setq yy (cadr y))
- (if (and xx yy (= xx yy))
- (setq nlst (subst (list (strcat (car y) "," (car x)) yy) y nlst))
- nil
- )
- )
- nlst)))
- (setq nlst (cons x nlst))
- )
- ) lst)
- (reverse nlst)
- )
|