I'm pretty new to Scheme and I'm currently working in DR Racket to learn it. So basically my problem is that I'm having trouble permanently changing global variable.
This is my change function:
(define (change b) (set! b (- b 1)) b) As you can note I return the value of a at the end of the function. And this is the output on the console.
> (define a 4) > (change a) 3 > a 4 As you can see, in the function it returned the value of 3 (4 - 1). But it seems as though the global variable didn't actually change when i call it after the function. How do I leave it changed? Thanks in advance.
a, then name the parameter ofchangethe same thing, and change the locala.int a = 5, then passato a fucntion where the variable is bound toband in it dob = b+1, why wouldn't the global variableachange? The same answer is valid for Scheme as well.