Re: accumulator generators



At 2008-05-30T19:50:43Z, Cameron <cameronlarue@xxxxxxxxx> 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, adding i to it, then assigning the
value back to the local variable named s.
--
Kirk Strauser
The Day Companies
.



Relevant Pages

  • [tip:x86/cleanups] x86: Clean up mtrr/cleanup.c
    ... static int __init ... save_var_mtrr(unsigned int reg, unsigned long basek, unsigned long sizek, ... unsigned long base, size, def, dummy; ...
    (Linux-Kernel)
  • Re: Getters and Setters
    ... public int getBar() ... The basic principle behind encapsulation is information hiding. ... private int value; ...
    (comp.lang.java.programmer)
  • RE: How to draw custom title bars on MDI child forms?
    ... The normal title bar background can be replaced with a bmp image. ... int titleheight = 0; ... g.FillRectangle(Brushes.Blue, 0, titleheight, borderwidth, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Large text files and searching text
    ... This header is not null or /n delimited as it just runs into the data ... The value is syntax for a quoted string in PostScript, and def is the assignment ... int data = headers.Find; ... BOOL FindIntParamter(const CString & pattern, const CString & headers, int & result) ...
    (microsoft.public.vc.mfc)
  • Re: Large text files and searching text
    ... This header is not null or /n delimited as it just runs into the data ... The value is syntax for a quoted string in PostScript, and def is ... int data = headers.Find; ... BOOL FindIntParamter(const CString & pattern, const CString & headers, int ...
    (microsoft.public.vc.mfc)