[plt-scheme] Changing the value of an variable

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Sat Apr 25 16:38:21 EDT 2009

Using 'define' to change a value only works at the REPL -- not in a
function, or in a module.  You probably want to use 'set!', as in
'(set! a n)'.  It works (just about) anywhere.

--Carl

On Sat, Apr 25, 2009 at 4:09 PM, Matthias Redies
<rediesmatthias at yahoo.de> wrote:
> I want to change the value of an variable. Until now I've always done it by
> '(define a 4)'
> but in this doesn't work in the following code:
> '(define a 3)
> (define (test n) (define a n))'
>
> Which command should I use instead? Sry if this question seem very silly,
> but I didn't find the answer any where.
>
>
> Mfg Matthias Redies


Posted on the users mailing list.