本帖最后由 xyp1964 于 2023-7-5 23:51 编辑
- ;|
- (abc '(1 2 3 4 5 6 7 8 9 10 11) 3)→((1 2 3) (4 5 6) (7 8 9) (10 11 ""))
- (abc '((1 2) (2 3) (3 4) (4 5) (5 6) (6 7) (7 8) (8 9) (9 10) (10 11 12) (11 12 13)) 3)
- →
- (((1 2) (2 3) (3 4)) ((4 5) (5 6) (6 7)) ((7 8) (8 9) (9 10)) ((10 11 12) (11 12 13) ""))
- |;
- (defun abc (lst n / bb tmp a)
- (setq bb '() tmp '())
- (while (setq a (car lst))
- (setq lst (cdr lst))
- (if (< (length tmp) n)
- (setq tmp (cons a tmp))
- (setq bb (cons (reverse tmp) bb)
- tmp (list a)
- )
- )
- )
- (if tmp
- (progn
- (while (< (length tmp) n) (setq tmp (cons "" tmp)))
- (setq bb (cons (reverse tmp) bb))
- )
- )
- (reverse bb)
- )
|