[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accumulator Reduc



This is neither here nor there, but Patrick Maupin wrote to mention that
although the right way to solve the "accumulator" problem in Python is a
class, ...

> you _can_ make Python as ugly and almost
> as compact as the lisp example:
> 
> from operator import setitem
> foo = lambda n: lambda i,s=[n]: setitem(s,0,s[0]+i) or s[0]

Yuck! This depends on so many accidental side-effects of various Python
features that it would take too much effort to explain why it works. But
still amusing.

 Paul Prescod