本帖最后由 vitalgg 于 2021-3-5 23:55 编辑
第二个元素没有用算法提取单位,均按 平方米 考虑。
 - (setq list1 '(("水泥路" "15.80平方米" "" "" "" "厚度为1m")
- ("水泥路" "22.00平方米" "" "" "" "无厚度")
- ("水泥路" "62.00平方米" "" "" "" "无厚度")
- ("水泥路" "100.00平方米" "" "" "" "无厚度")
- ("女儿墙" "6.85平方米" "8.05米" "0.85米" "0.12米" "有顶")
- ("女儿墙" "22.00平方米" "8.05米" "0.85米" "0.12米" "有顶")))
- (defun union-lst (list1 / list2)
- (setq list2 '())
- (foreach x% list1
- (if (member (cons (car x%) (cdddr x%)) (mapcar '(lambda (x) (cons (car x) (cdddr x))) list2))
- (progn
- (foreach at% list2
- (if (equal (cons (car x%) (cdddr x%))
- (cons (car at%) (cdddr at%)))
- (progn
- (setq list2 (subst (append (list (car x%)
- (strcat (rtos (+ (atof (nth 1 x%)) (atof (nth 1 at%))) 2 2) "平方米")
- (nth 2 x%))
- (cdddr x%))
- at%
- list2)))
- )
-
- ))
- (progn
- (setq list2 (append list2 (list x%)))))
- )
- list2
- )
- (print (union-lst list1))
- (princ)
|