本帖最后由 qjchen 于 2012-4-26 11:19 编辑
xshrimp 发表于 2012-4-24 18:48
命令: (tst (list 1 2 3 4 5 6))
((1 2 3) (2 3 4) (3 4 5) (4 5 6) (5 6 1) (6 1 2))
gu兄和xshrimp兄都是好方法:)
也凑下热闹写一个递归的
- (defun q:lst2(lst)
- (q:lst1 (append lst (list (car lst) (cadr lst))))
- )
- (defun q:lst1(lst)
- (cond ((not (caddr lst)) nil)
- (T (cons (list (car lst) (cadr lst) (caddr lst)) (q:lst1 (cdr lst))))
- )
- )
- (q:lst2 (list 1 2 3 4 5 6))
|