
March 18, 2010
11:02 p.m.
On Mar 18, 5:01 pm, Andrey Fedorov <anfedo...@gmail.com> wrote:
spir wrote:
A "parameterisable" generator factory: [...]
Good lord, no! Nooo!
"power" is one thing with one semantic meaning "range" is another thing with another semantic meaning
There is absolutely no excuse for mixing the two implementation into a "power-range" monstrosity. Implement the two separately and make some custom function composition like:
def pow(x, n): return x**n
def pow_o_range(n, a, b): return [(x, pow(x, n)) for x in range(a,b)]
for i, x in pow_o_range(3, 1, 10): print "%s:%s" % (i,x),
# prints "1:1 2:8 3:27 4:64 5:125 6:216 7:343 8:512 9:729"
i was just an example to demonstrate the usage dude, :)