- (defun c:tt ()
- (defun count (lst / a b b1 lst1 lst2)
- (setq lst (vl-sort lst '(lambda (x y) (< (car x) (car y))))
- a (car lst)
- b (car a)
- lst (cdr lst)
- lst1 (list b (cdr a))
- lst2 '()
- )
- (while (setq a (car lst))
- (setq b1 (car a)
- lst (cdr lst)
- )
- (if (equal b1 b)
- (setq lst1 (append lst1 (list (cdr a))))
- (setq lst2 (cons lst1 lst2)
- lst1 (list b1 (cdr a))
- b b1
- )
- )
- )
- (reverse (cons lst1 lst2))
- )
- (setq lst '(("建筑S=" "21")
- ("厨房S=" "68")
- ("建筑S=" "357")
- ("楼梯间S=" "62")
- ("楼梯间S=" "53")
- )
- lst (count lst)
- lst (mapcar '(lambda (x)
- (setq b (apply 'append (cdr x))
- b (apply '+ (mapcar 'atoi b))
- )
- (list (car x) b)
- )
- lst
- )
- )
- (princ lst)
- (princ)
- )
结果:(("厨房S=" 68) ("建筑S=" 378) ("楼梯间S=" 115)) |