6 ms·
That won't quite work, as you're still just copying the value of i when that function is executed, which will be 4. You could make the function take a paramete
by theoretical 16y ago
That won't quite work, as you're still just copying the value of i when that function is executed, which will be 4.
You could make the function take a parameter, then return a function which uses that parameter, or use currying.
Edit: I've posted a working version in my comment further down, http://news.ycombinator.com/item?id=2124559 http://news.ycombinator.com/item?id=2124559