News for hackers. Stuff that matters.
Re:Thinking About Recursion by komali2 on Wednesday March 08, 2017 @07:22PM (#13825374)
I don't really know much about functional programming. How can a variable not change?
Re:Thinking About Recursion by crimsonalucard on Wednesday March 08, 2017 @07:29PM (#13825439)
In functional programming the entire program is literally a single expression. This is essentially what functional programming is. A variable in a single expression cannot be modified.
Re:Thinking About Recursion by clusmore on Wednesday March 08, 2017 @07:30PM (#13825452)
In mathematics, variables don't change inside expressions -- they define a family of expressions, each with a different value. For example, in the function

  f(x) = x^2 + x + 1
the value of x in the right-hand-side expression doesn't change in the same sense that variables in imperative languages change. But it allows the single expression "x^2 + x + 1" to have a value which varies by the value of x. For example, f(2) yields the value 7 while f(3) yields the value 13.
Re:Thinking About Recursion by dualogy on Thursday March 09, 2017 @05:57AM (#13828465)
Construct a whole program of functions only with say `readonly` (in c#) or `const` (in EcmaScript) or only `:=` (in Go) "variable" "assignment-declarations", never mutating them after initial declaration. It's possible and it's one of the core tenets of purely FP.