vary number of loops
nullgraph at gmail.com
nullgraph at gmail.com
Wed Apr 16 09:31:04 EDT 2008
Hi everyone,
I'm new to Python and the notion of lambda, and I'm trying to write a
function that would have a varying number of nested for loops
depending on parameter n. This just smells like a job for lambda for
me, but I can't figure out how to do it. Any hint?
For example, for n=2, I want the function to look something like:
def foo(2)
generate 2 sets of elements A, B
# mix elements by:
for a_elt in A
for b_elt in B
form all combinations of them
If n=3, I want to have 3 sets of elements and mix them up using 3 for
loops.
Any help is greatly appreciated,
nullgraph
More information about the Python-list
mailing list