本帖最后由 夏生生 于 2022-2-27 16:02 编辑
谢谢您,完美解决
- (defun f2 (lst m n / i lsta)
- (defun f1 (a m n / fflst flst i j vlst)
- (setq flst (list a a)
- i 0
- j (max 1 (- a n))
- vlst nil
- )
- (while (<= j a)
- (while (< i (- m 2))
- (setq fflst (list j))
- (repeat i
- (setq fflst (cons j fflst))
- )
- (setq vlst (cons fflst vlst))
- (setq i (+ i 1))
- )
- (setq j (+ j 1)
- i 0
- )
- )
- (setq
- vlst (mapcar '(lambda (x) (cons a (reverse (cons a x)))) vlst)
- )
- (setq vlst (cons flst (reverse vlst)))
- )
- (setq i (1+ (length lst))
- lsta nil
- )
- (repeat (1- i)
- (setq lsta (cons (f1 (setq i (1- i)) m n) lsta))
- )
- (setq
- lst
- (mapcar '(lambda (x) (mapcar '(lambda (y) (nth (1- y) lst)) x))
- (apply 'append lsta)
- )
- )
- )
- (f2 '("a" "b" "c" "d" "e") 4 2)(("a" "a") ("a" "a" "a") ("a" "a" "a" "a") ("b" "b") ("b" "a" "b") ("b" "a" "a" "b") ("b" "b" "b") ("b" "b" "b" "b") ("c" "c") ("c" "a" "c") ("c" "a" "a" "c") ("c" "b" "c") ("c" "b" "b" "c") ("c" "c" "c") ("c" "c" "c" "c") ("d" "d") ("d" "b" "d") ("d" "b" "b" "d") ("d" "c" "d") ("d" "c" "c" "d") ("d" "d" "d") ("d" "d" "d" "d") ("e" "e") ("e" "c" "e") ("e" "c" "c" "e") ("e" "d" "e") ("e" "d" "d" "e") ("e" "e" "e") ("e" "e" "e" "e"))
|