本帖最后由 dcl1214 于 2024-6-28 13:25 编辑
①为了方便人的记忆或者是单元格写不下等原因,发现基于36进制或者是64进制来生成的字串只需要4位就能描述百万级数据量
②cad的图元句柄也是类似原理,上不封顶的升位法
- (DEFUN $sheng-wei$ (str LST / a as s s-new str-new to zz zz-mw)
- ;进制升位
- ;示例($sheng-wei$ "ZzZ" nil)
- (SETQ ZZ (list "0" "1" "2" "3" "4" "5" "6" "7" "8"
- "9" "A" "B" "C" "D" "E" "F" "G" "H"
- "I" "J" "K" "L" "M" "N" "O" "P" "Q"
- "R" "S" "T" "U" "V" "W" "X" "Y" "Z"
- "a" "b" "c" "d" "e" "f" "g" "h" "i"
- "j" "k" "l" "m" "n" "o" "p" "q" "r"
- "s" "t" "u" "v" "w" "x" "y" "z" "+"
- "-"
- )
- )
- (if (AND str
- (= (TYPE str) 'str)
- (SETQ S (MAPCAR 'CHR (vl-string->list str))) ;列表
- (SETQ S (vl-remove-if-not
- (FUNCTION (LAMBDA (A) (CAR (MEMBER A ZZ))))
- S
- )
- )
- ;传入进来的字串必须在ZZ列表中能找到
- )
- (progn
- (SETQ zz-mw (last zz)) ;列表末尾那位
- (setq ZZ (reverse (cons (car zz) (reverse zz))))
- ;将列表中第一个字串追加到列表的尾巴上,便于member搜索
- (setq As nil)
- (SETQ S (REVERSE S)) ;倒置
- (IF (eval (cons '= (cons zz-mw S))) ;如果已经是最大数了
- (setq S (cons (car ZZ) S)) ;直接升位
- (PROGN
- (setq to t)
- (while (and to (setq a (car s))) ;满足条件
- (if (= a zz-mw) ;如果当前字串已经是列表中最后一个字串了
- () ;不执行任何动作
- (setq to nil) ;结束while循环
- )
- (setq a (CADR (member a ZZ))) ;查找下一个字串
- (setq As (cons a As)) ;追加到变量as的记录里面
- (setq s (cdr s)) ;S列表移除第一个便于while循环
- )
- )
- )
- (setq As (reverse As)) ;倒置回去
- (setq s-new (reverse (append As s)))
- ;while还没有循环完的部分和已经升位后的部分合并
- (setq str-new (APPLY 'strCAT s-new)) ;拼接新字串
- )
- )
- str-new ;返回新字串
- )
|