Community
If the issue is that (max) doesn't like nil as an argument:
Command: (max 12 15 nil 75 34)
; error: bad argument type: numberp: nil
then if you can put the values into a list, and get rid of any nil's in it, you can find the maximum of the numerical values:
Command: (apply 'max (vl-remove nil '(12 15 nil 75 34)))
75
Or, if there might be other kinds of non-numerical values than just nil:
Command: (max 45.3 "what" 98 12.34)
; error: bad argument type: numberp: "what"
you can do something similar, removing anything that isn't a number:
Command: (apply 'max (vl-remove-if-not '(lambda (x) (numberp x)) '(45.3 "what" 98 12.34)))
98.0