假设您的字符串格式一致,这似乎可行:
- (vl-load-com)
- (defun _AddToRightSide (increment yourList / BB:Parser newList)
- (defun BB:Parser (char string / i segments segment)
- ;; Example: (BB:Parser "-" "dd-mm-yyyy")
- ;; Returns: ("dd" "mm" "yyyy")
- (while (setq i (vl-string-search char string))
- (setq segments (cons (setq segment (substr string 1 i)) segments))
- (setq string (substr string (+ 2 i)))
- )
- (reverse (cons string segments))
- )
- (foreach item yourList
- (setq newList
- (cons
- (vl-string-right-trim
- "*"
- (apply
- 'strcat
- (mapcar
- (function (lambda (x) (strcat x "*")))
- (reverse
- (cons
- (itoa
- (+ (atoi
- (car
- (setq segments (reverse (BB:Parser "*" item)))
- )
- )
- increment
- )
- )
- (cdr segments)
- )
- )
- )
- )
- )
- newList
- )
- )
- )
- (reverse newList)
- )
... 例子:
- _$ (_AddToRightSide
- -10
- (list
- "[color="red"]100[/color]*M16*50" "1*M16*50" "1*M[color="red"]1600[/color]*50" "5*M16*65" "2*M16*80" "3*M16*85" "1*M20*55"
- "4*M20*70" "2*M20*85" "2*M20*90" "2*M20*[color="red"]900[/color]" "2*M20*[color="red"]1000[/color]"
- )
- )
- ("[color="red"]100[/color]*M16*40" "1*M16*40" "1*M[color="red"]1600[/color]*40" "5*M16*55" "2*M16*70" "3*M16*75" "1*M20*45" "4*M20*60" "2*M20*75" "2*M20*80" "2*M20*[color="red"]890[/color]" "2*M20*[color="red"]990[/color]")
- _$
干杯 |