I have strong feeling that the code below is ugly at least as there are 2 same "cons".
I would appreciate if you advise me ways to improve it.
The code produces all allocation by n items from list lst.
(defun allocations (lst n)
(if (= n 1)
(loop for i in lst
collect (cons i nil))
(loop for i in lst
append (mapcar #'(lambda (l) (cons i l))
(allocations (remove i lst) (- n 1))))))
lstandlcan be improved by expanding them to the full length. The first branch in theifis equivalent to(mapcar #'list lst). – wvxvw Dec 14 '12 at 13:08