[Haskell-cafe] Change value of a variable

Bulat Ziganshin bulat.ziganshin at gmail.com
Sun Jun 7 14:01:31 EDT 2009

Hello ptrash,

Sunday, June 7, 2009, 9:41:56 PM, you wrote:

> Hi, how can I change the value of a variable.

there are no variables in haskell :)))

x, like any other identifier, is a value. when you translate to Haskell
some algo that needs to update variable contents, you may either

1) use recursion:

length (x:xs) = 1 + length xs
length [] = 0

2) use references (IORef). like in C, references by itself are non-mutable,
but they point to values that can be mutated

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list