黄翔 发表于 2024-8-19 00:41:55

(defun abc(_str / LM:lst->str LM:str->lst _alst_xlst )
(defun LM:lst->str ( lst del )
    (if (cdr lst)
      (strcat (car lst) del (LM:lst->str (cdr lst) del))
      (car lst)
    )
)
(defun LM:str->lst ( str del / pos )
    (if (setq pos (vl-string-search del str))
      (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
      (list str)
    )
)
(LM:lst->str
(apply 'append
(mapcar '(lambda(x)
    (setq _alst nil)
    (cond
      ((wcmatch x "*`**")
      (setq _xlst (LM:str->lst x "*"))      
      ((lambda(y z)(repeat (atoi z) (setq _alst (cons y _alst)))_alst)(car _xlst)(cadr _xlst))      
      )
      (t (list x))
    )
)(LM:str->lst _str " "))) " ")
)
命令: (abc "50 100*3 200*2 100*1")
"50 100 100 100 200 200 100"

大角牛 发表于 2024-8-19 09:43:05

黄翔 发表于 2024-8-19 00:41
命令: (abc "50 100*3 200*2 100*1")
"50 100 100 100 200 200 100"

感谢感谢感谢

大角牛 发表于 2024-8-19 09:44:11

xyp1964 发表于 2024-8-18 22:27


感谢,这个需要下载工具箱才能运行吧
页: 1 [2]
查看完整版本: 如何将输入50*3这类乘法数据转换为50+50+50这类的加法?