The code below gives me the list of sublists of a list. Code can still be improved to avoid the use of append, right?
(defun sublists (alist)
(labels ((aux (list p r)
(if (null list)
(append r (maplist #'identity p))
(aux (cdr list)
(append p (list (car list)))
(append r (maplist #'identity p))))))
(aux alist nil nil)))
CL-USER> (sublists (list 1 2 3 4))
((1) (1 2) (1 2 3) (1 2 3 4) (2) (2 3) (2 3 4) (3) (3 4) (4))
ideas? This question was posted in https://stackoverflow.com/questions/49019045/pure-functional-code-for-the-sublists-of-a-list originally.