Talk:Functional programming: Difference between revisions

Content deleted Content added
Line 149:
:P.S. Technically you can have global variables in a pure functional language, as long as they're immutable. "Global" is a term describing the [[Scope (computer science)|scope]] of a variable, not its changes in state. Having no state changes in ''any'' variable in the whole program is a rather strong requirement, which changes the programming paradigm significantly with respect to imperative programming. [[User:Diego Moya|Diego]] ([[User talk:Diego Moya|talk]]) 12:52, 24 April 2017 (UTC)
::Thanks. So b=2*a is ok, but a=2*a is not? I can see that that is more robust in general, if a tad inconvenient for incrementing indices. [[User:Greglocock|Greglocock]] ([[User talk:Greglocock|talk]]) 00:31, 25 April 2017 (UTC)
::: Yes, that's pretty much the essence; destructive updates to named variables are not allowed. The typical way of "incrementing indices" is passing the increased value to a recursive call; functional programming depends heavily on [[recursion]]. [[User:Diego Moya|Diego]] ([[User talk:Diego Moya|talk]]) 06:16, 25 April 2017 (UTC)