请教了俄罗斯高手:ElpanovEvgeniy 后源程序大大简化,速度极快
- (defun SumPartCounts (bom_lst / f)
- (defun f (a bom_lst)
- (if a
- (* (atoi (caddr a)) (f (assoc (cadr a) bom_lst) bom_lst))
- 1
- ) ;_ 结束if
- ) ;_ 结束defun
- (mapcar (function (lambda (a) (itoa (f a bom_lst))))
- bom_lst
- ) ;_ 结束mapcar
- ) ;_ 结束defun
(setq bomlst '(
("sub-assembly1-1" "assembly" "2")
("sub-assembly1-2" "assembly" "3")
("sub-assembly1-3" "assembly" "1")
("pat1-1" "assembly" "3")
("pat1-2" "assembly" "2")
("pat1-3" "assembly" "5")
("sub-assembly2-1" "sub-assembly1-1" "2")
("sub-assembly2-2" "sub-assembly1-1" "2")
("sub-assembly2-3" "sub-assembly1-1" "4")
("pat2-1" "sub-assembly1-1" "3")
("pat2-2" "sub-assembly1-2" "4")
("pat1-3" "sub-assembly1-1" "2")
("pat3-1" "sub-assembly1-3" "2")
("pat3-2" "sub-assembly1-3" "3")
("pat2-1" "sub-assembly1-2" "1")
("none" "sub-assembly2-2" "3")
("none" "sub-assembly2-1" "3")
)
) ;_ 结束setq
(SumPartCounts bomlst);=>("2" "3" "1" "3" "2" "5" "4" "4" "8" "6" "12" "4" "2" "3" "3" "12" "12")
|