How to fix the 'cannot change constant' error

Joe

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.

R Sahu

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to fix "Cannot use mutating member on immutable value: 'cleanup' is a 'let' constant" error?

How to fix "Expression must have a constant value" when the value cannot be constant?

How to fix "NameError: uninitialized constant Thor::Base" error?

How to fix 'constant x oveflows byte' error in go?

How to fix a constant IO error cause by a Non-Readable file?

How can I fix the Expected a constant as index error?

How to fix error "Cannot resolve column..."

How to fix "Cannot read property of undefined" error

How to fix INET error "Cannot load library"

How to fix error with MySQL because of timezone change?

How to fix Uninitialized Constant in Controller

How to fix this error Cannot run program "svn" Error in Java

how to fix the error "ERROR TypeError: Cannot read property '0' of undefined"

How to fix error: Fontconfig error: Cannot load default config file

How to fix Cannot parse "DATE" constant issue in H2 Database?

How can I fix this error "the value of 'x1' is not usable in a constant expression" ? static_assert

How can I fix 'non_constant_list_element' error in flutter?

How to fix 'ActionController::RoutingError (uninitialized constant someController)' error in ruby on rails 5

how to fix this verilog part-select error: Illegal operand for constant expression

How to fix Warning: Use of undefined constant active - assumed 'active' (this will throw an Error in a future version of PHP)

How to fix "ERROR TypeError: Cannot set property 'id' of undefined "

How to fix the "ERROR TypeError: Cannot read property 'style' of undefined"

How to fix `The system cannot find the path specified` error on Windows 10?

How to fix 'Cannot read property of undefined' error in Angular post request

How to fix error: cannot find symbol in android studio SQLite database

How do i fix "cannot call rma with arguments" error?

How to fix the error: incompatible types: MenuFragment cannot be converted to Fragment in android?

How to fix "error:cannot generate COM file, stack segment present"?

How to fix "Cannot read property 'trim' of undefined" error in node