本帖最后由 xyp1964 于 2024-8-19 11:19 编辑
- ;; (abc "50 100*2 200*3") → (50 100 100 200 200 200)
- (defun abc (tx)
- (defun aa (tx / nn t1 t2 lst)
- (setq nn (vl-string-search "*" tx)
- t1 (substr tx 1 nn)
- t2 (substr tx (+ nn 2))
- )
- (if (and (setq a (atoi t1)) (setq n (atoi t2)))
- (repeat n (setq lst (cons a lst)))
- )
- lst
- )
- (apply 'append(mapcar '(lambda (x)(i(vl-string-search "*" x)(aa x)(list (atoi x))))(xyp-StrSpr tx " ")))
- )
- (defun xyp-StrSpr (str sub / lst n)
- "以指定分解符分解字符串"
- (if (/= sub "")
- (progn
- (while (setq n (vl-string-search sub str))
- (setq lst (cons (substr str 1 n) lst)
- str (substr str (+ n (strlen sub) 1))
- )
- )
- (vl-remove "" (reverse (cons str lst)))
- )
- )
- )
|