Kay Schluehr wrote: > I want to manipulate a deeply nested list in a generic way at a > determined place. Given a sequence of constant objects a1, a2, ..., aN > and a variable x. Now construct a list from them recursively: > > L = [a1, [a2, [....[aN, [x]]...]] > > The value of x is the only one to be changed. With each value of x a > new instance of L is needed so that we actually have a function: > > L = lambda x: [a1, [a2, [....[aN, [x]]...]] > > I'm seeking for an efficient implementation that does not recompute the > whole list each time. Any ideas?
The problem is that all your lists/sublists have different values. "recompute" doesn't really even apply. If x != y, then no two sublists found within L(x) plus L(y) are equal (excluding sublists that might be within x or y). -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list