[Haskell-cafe] Change value of a variable

Keith Sheppard keithshep at gmail.com
Sun Jun 7 14:46:30 EDT 2009

I guess the short answer is that it is not possible. 'x' is immutable
and if you want a different value than 'x' that expression has to be
given a different name like:
let x=1

But I'm not sure if that helps you. Haskell does things very
differently than the imperative languages and forces you to think
differently about how to solve problems. When I started learning
haskell I found that I had to think more about composing/decomposing
expressions and less about sequencing actions and side effects like
you do in most of the more popular languages (I really have come to
prefer the Haskell way). I think we may be able to give a more helpful
answer if give a more high level algorithm/use case... why do you want
to change the value of x


On Sun, Jun 7, 2009 at 1:41 PM, ptrash<ptrash at web.de> wrote:
> Hi, how can I change the value of a variable.
> let x = 1
> x = x + 2
> First I set the value of x to 1. Then I want to increase it by 2. This way
> doesn't work, because I think it is a infinite expression.
> Is there a way to change the value?
> --
> View this message in context: http://www.nabble.com/Change-value-of-a-variable-tp23913404p23913404.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list