Re: accumulator generators

2008-05-31 Thread Arnaud Delobelle
George Sakkis <[EMAIL PROTECTED]> writes: > On May 31, 4:19 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: >> Cameron <[EMAIL PROTECTED]> writes: >> > I was reading this http://www.paulgraham.com/icad.html";>Paul >> > Graham article and he builds an accumuator generator function in >> > the appen

Re: accumulator generators

2008-05-31 Thread George Sakkis
On May 31, 4:19 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > Cameron <[EMAIL PROTECTED]> writes: > > I was reading this http://www.paulgraham.com/icad.html";>Paul > > Graham article and he builds an accumuator generator function in > > the appendix. His looks like this: > > > > > def foo(n):

Re: accumulator generators

2008-05-31 Thread Arnaud Delobelle
Cameron <[EMAIL PROTECTED]> writes: > I was reading this http://www.paulgraham.com/icad.html";>Paul > Graham article and he builds an accumuator generator function in > the appendix. His looks like this: > > > def foo(n): > s = [n] > def bar(i): > s[0] += i > return s[0] > return ba

Re: accumulator generators

2008-05-30 Thread Hans Nowak
Cameron wrote: On May 30, 1:04 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: Cameron schrieb: I was reading this http://www.paulgraham.com/icad.html";>Paul Graham article and he builds an accumuator generator function in the appendix. His looks like this: def foo(n): s = [n] def bar

Re: accumulator generators

2008-05-30 Thread Cameron
On May 30, 1:04 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Cameron schrieb: > > > > > I was reading this http://www.paulgraham.com/icad.html";>Paul > > Graham article and he builds an accumuator generator function in > > the appendix. His looks like this: > > > > > def foo(n): > >   s = [

Re: accumulator generators

2008-05-30 Thread Kirk Strauser
At 2008-05-30T19:50:43Z, Cameron <[EMAIL PROTECTED]> writes: > Why does that work, but not this: > > def foo(n): > s = n > def bar(i): > s += i > return s > return bar Assume that n is an int, making s one also. Ints are immutable; you can only copy them. So your bar is taking s,

Re: accumulator generators

2008-05-30 Thread Diez B. Roggisch
Cameron schrieb: I was reading this http://www.paulgraham.com/icad.html";>Paul Graham article and he builds an accumuator generator function in the appendix. His looks like this: def foo(n): s = [n] def bar(i): s[0] += i return s[0] return bar Why does that work, but not this: