Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If you want various levels in the list, you probably want the original as well. You could do

id = lambda a: a
ops=[id,R1,R2,R3,R4]
L=[v]
for i in range(10):
  L = [f(v) for v in L for f in ops]

which has the slight perk that it reuses some of the intermediate results.

If you want various levels in the list, you probably want the original as well. You could do

id = lambda a: a
ops=[id,R1,R2,R3,R4]
ops=[R1,R2,R3,R4]
L=[v]
for i in range(10):
  L = += [f(v) for v in L for f in ops]

which has the slight perk that it reuses some of the intermediate results.

If you want various levels in the list, you probably want the original as well. You could do

ops=[R1,R2,R3,R4]
L=[v]
T=[v]
L=[]
for i in range(10):
  L += T
  T = [f(v) for v in L T for f in ops]