In scheme which is a functional programming language, there is no assignment statement.
But in a let statement
(let ((x 2))
(+ x 3))
You are assigning 2 to x, so why doesn’t this violate the principle that there is no assignment statements in functional programming?
The statement “Scheme which is a functional programming language” is incorrect. In Scheme, a functional-programming style is encouraged, but not forced. In fact, you can use
set!(an assignment statement!) for modifying the value of any variable:Regarding the
letstatement of the question, remember that an expression such as this one:… it’s just syntactic sugar, and under the hood it’s implemented like this:
Notice that a
letperforms one-time single assignments on its variables, so it doesn’t violate any purely functional programming principle per se, the following can be affirmed of aletexpression:Also, quoting from Wikipedia: