本帖最后由 llsheng_73 于 2015-8-17 15:20 编辑
- (defun subtotals(lst m / a b c d)
- (foreach x lst
- (setq a(if(setq c(nth m x)d(list(vl-remove c x))b(assoc c a))
- (subst(append b d)b a)
- (append a(list(append(list c)d)))))))
- (defun tt(lst / i)
- (vl-sort(apply'append(mapcar'(lambda(x)(setq i 0)
- (mapcar'(lambda(y)(setq i(1+ i))
- (cons(read(strcat(vl-princ-to-string(car x))
- (if(>(length(cdr x))1)(itoa i)"")))y))(cdr x)))
- (subtotals lst 0)))'(lambda(x y)(< (vl-princ-to-string(car x))(vl-princ-to-string(car y)) )))
- )
$ (tt'((F 立柱 1)(F 侧面 2)(B 立面 1)))==>((B 立面 1)(F1 立柱 1) (F2 侧面 2)) |