/ takes one or more numbers as arguments, but in your code you pass it a list - it is clear that this will not work. The apply function is your friend here - (apply #'foo ab (list cde)) equivalent to (foo abcde) . Note that the apply arguments between the function used and the destination list are optional, therefore (apply #'/ '(20 2 5)) equivalent to (/ 20 2 5) .
Also, trying to remove zeros will not work. dolist evaluates its body for each element in the elements argument list, but you actually do nothing to change the contents of the elements (the result of computing the dolist body dolist not reassigned to the original element as you seem to expect).
The remove-if functions (and its destructive counterpart delete-if ) are what you are looking for. The following shows how to use it (it takes a lot of optional arguments that you don't need to worry about for this purpose).
(defun divtest (elements) (apply
Also note that this will not lead correctly if the elements list does not have zero as the first element (if I understand what the function should do). So you may want something like
(defun divtest (elements) (apply
See Hyperspec for details.
source share