Well, you can always implement your own my-max
and use it instead of the built-in max
procedure:
(define (my-max a b)
(if (> a b) a b))
You'll have to do basically the same comparison, one way or another, for finding the maximum depth - so it's ok to refactor it to a helper procedure. Notice that it wouldn't be a good idea to in-line the comparison, because that would entail evaluating twice the recursive calls - better stick to using a helper procedure, be it max
or my-max
.
Also, the second call to max
is unnecessary in your code - if there's only one value, why do you need to find the maximum?