(defun get_s(lst) (cond ( (eql lst nil) 0 ) ( (eql (car lst) 1) (+ 1 (get_s (cdr lst))) ) ( 1 1) ) ) (defun dec_trunc(lst s c) (cond ((eql lst nil) nil) ((eql s c) (list (- (car lst) 1)) ) ( 1 (cons (car lst) (dec_trunc (cdr lst) s (+ c 1))) ) ) ) (defun sum(lst s c) (cond ((eql lst nil) 0) ((< c s) (+ (car lst) (sum (cdr lst) s (+ c 1)) )) ( 1 (sum (cdr lst) s (+ c 1)) ) ) ) (defun next(lst) (setq k (length lst)) (setq sum_all (sum lst (+ k 1) 1)) (setq s (- (+ k 1) (get_s (reverse lst)))) (setq lst (dec_trunc lst s 1)) (setq sum_now (sum lst (+ (length lst) 1) 1)) (setq ds (car(last lst))) (loop ( cond ((eql sum_now sum_all) (return lst)) ) ( cond ((eql ds 0) (return nil)) ) ( cond ( (<= (+ sum_now ds) sum_all) (setq lst (append lst (list ds))) (setq sum_now (+ sum_now ds)) ) ( 1 (setq ds (- ds 1)) ) ) ) ) (next '(10)) (next (next '(10))) (next (next (next '(10)))) (next (next (next (next '(10))))) (system)