17 lines
658 B
Common Lisp
17 lines
658 B
Common Lisp
(defun all-subsequences2 (list)
|
|
(labels ((recurse (s list)
|
|
(if (endp list)
|
|
(if (>= s 3)
|
|
'(())
|
|
'())
|
|
(let ((x (car list))
|
|
(xs (cdr list)))
|
|
(if (evenp s)
|
|
(append (mapcar (lambda (ys) (cons x ys))
|
|
(recurse (+ s 1) xs))
|
|
(recurse s xs))
|
|
(append (mapcar (lambda (ys) (cons x ys))
|
|
(recurse s xs))
|
|
(recurse (+ s 1) xs)))))))
|
|
(recurse 0 list)))
|