 - ;|6.按指定长度,分割一个表,成多个小表
- 格式:(ListSplit1 lst len)
- lst:要分割的表
- len:int 子表长度
- 比如:(ListSplit1 '(0 1 2 3 4 5 6 7 8 9) 3)
- 返回 '((0 1 2) (3 4 5) (6 7 8) (9))
- |;
- (defun ListSplit1(lst len / nl)
- (while (and lst (> (length lst) len))
- (setq nl1 nil)
- (repeat len
- (setq nl1 (cons (car lst) nl1)
- lst (cdr lst))
- )
- (setq nl (cons (reverse nl1) nl))
- )
- (reverse (cons lst nl))
- )
我新手 咱也试试
|