Variable Assignment in Haskell

In Haskell when you define a variable you cannot change that variable values unlike Imperative languages.

Image for post
Image for post
Assignment
int value = 0 value = 1 // We can update the value In this case to 1
Prelude> inc x = x + 1Prelude> xinc x = inc x Prelude> inc 1
2
Prelude> xinc 1
2
Prelude> inc x = x + 2
Prelude> inc 1
3
Prelude> xinc 1
2

Resources

  1. https://stackoverflow.com/questions/35198897/does-mean-assigning-a-variable-in-haskell

Written by

Software developer | blog.maqbool.net

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store