[I]For 楼主的第二题。[/I]本来对此贴不感兴趣,但楼主盛情难却。没有什么意思,不过可以测试一下您的计算机运行速度,来个 (all-sequences '(a b c d e f g h i)) 试试?
;;;By xazhji 21:53 2005-10-8 (defun all-sequences (lis / li1 li2 m mm n nlis nnlis xx yy) (setq nlis (list (list (car lis)))) (foreach xx (cdr lis) (progn (setq nnlis nil) (foreach yy nlis (progn (setq n 0 ) (repeat (1+ (length yy)) (setq m 0 mm n li1 nil li2 nil) (repeat n (setq li1 (cons (nth m yy) li1) m (1+ m))) (repeat (- (length yy) n) (setq li2 (cons (nth mm yy) li2) mm (1+ mm))) (setq nnlis (append (list (append (reverse li1) (cons xx (reverse li2)))) nnlis) n (1+ n)) ) (setq nlis nnlis) ) ) ) ) ) |