Re:PG: If starting Viaweb today, would you use Lisp?
by earthboundkid on Sunday July 29, 2007 @06:09AM
(#37428)
If it's supposed to be an accumulator, I take it they want the value of n to be changed each time. I'd do:
def acc(n):
while True:
n += yield n
The Python version listed there doesn't actually meet the requirement (it doesn't return a function, it returns a class instance, and it keeps modifying n every time it's called).
Corrected version:
Which is essentially identical to the Common Lisp version.