News for hackers. Stuff that matters.
Re:Functors, applicatives, and monads in pictures by chongli on Sunday May 19, 2013 @11:17AM (#5733062)
Right, but you're not mutating it in the middle of your calculation.
Re:Functors, applicatives, and monads in pictures by Gravityloss on Sunday May 19, 2013 @01:47PM (#5733687)
If you have a sum for example sum_{x=1}^{10}x^2, x definitely changes quite many times during your calculation.
Re:Functors, applicatives, and monads in pictures by chongli on Sunday May 19, 2013 @03:43PM (#5734136)
No, that's an example of recursion. With recursion you aren't mutating the variable, you're shadowing its definition. This is a subtle, but important, distinction.
Re:Functors, applicatives, and monads in pictures by Gravityloss on Sunday May 19, 2013 @04:51PM (#5734348)
Recursion? The "function" is not calling itself at all. I'm quite sure that is not recursion, neither in the mathematical nor computer science sense.
Re:Functors, applicatives, and monads in pictures by chongli on Sunday May 19, 2013 @05:57PM (#5734570)
Recursion is how you implement a sum without mutation (an imperative loop is how you'd implement it with mutation). You've merely given me the function written in a declarative notation.
Re:Functors, applicatives, and monads in pictures by Gravityloss on Tuesday May 21, 2013 @11:54AM (#5744509)
I think we are talking about different things.

For example, if you integrate x^2 dx from x=0 to 10, x changes continuously.

It's clear that x is not fixed to any particular value.

Re:Functors, applicatives, and monads in pictures by chongli on Wednesday May 29, 2013 @05:32AM (#5785400)
Yeah, you're talking about the mathematical definition of a bound variable. Functional programming languages use this whenever you define a function:

   foo x = x * 2
Every time you call foo, x is bound to a new value (but only within the scope of foo). This is not the same as mutating some memory location associated with the name x.
Re:Functors, applicatives, and monads in pictures by chousuke on Monday May 20, 2013 @01:26PM (#5738792)
x does not mutate at all. x is simply a placeholder for the values in the series of additions that your expression expands to, that is, 1² + 2² + 3² + ... + 10². Or stepwise, to 1² + sum_{x=2}^{10}x² etc. all three expressions are equivalent, and no mutation of x occurs anywhere

The series of additions can also be infinite, in which case it would be quite difficult to expand fully, but that doesn't prevent you from doing mathematics with it.