I have this code so far
(define (max f g)
(define (int-max x y)
(if (> x y) x y))
(lambda (x) (int-max (f x) (g x))))
it gives me the error define-values: assignment disallowed;
cannot change constant
constant: max
I'm not sure how to fix this or what it means.
The problem you are facing is that max
is already defined and you are trying to re-define it.
More importantly, name max
is not appropriate for what you are trying to use it for. You are calling max
with couple of arguments that are functions. It returns a lambda
that can be invoked with a variable.
Your envisioning usage such as
((max sin cos) 10)
A name such as max-proc-value
would be more appropriate and will avoid the problem that you have run into.