(defun boolean-values (n) (let ((result '((t) (nil)))) (dotimes (i (1- n) result) (let ((new-result '())) (dolist (thing result) (push (cons nil thing) new-result) (push (cons t thing) new-result)) (setf result new-result))))) CL-USER> (boolean-values 3) ((T NIL T) (NIL NIL T) (T T T) (NIL T T) (T NIL NIL) (NIL NIL NIL) (T T NIL) (NIL T NIL))