it still looks bigger and more complex than doing recursion. what i am worried about next is whether or not i can do a yield in the recursive function. during the many loops in the recursion there is a point where the total equals or exceeds a limit. if it exceeds the limit, that last loop is broken out of and the recursion returns to the previous loop for it next try. but if it equals the limit, i want to yield the list of all the iterated values before doing that recursion descent. i just want to be sure that yield mechanism can resume the recursive stack. i supposed i can just try it and see. the alternative would be to print the list and have the code that needs to process these values just read them from a pipe. each loop in one recursion has the same range. there will be many such recursions being run to look for specific results each with different ranges. this may involve a lot of CPU time. hopefully, your code ideas overcome that extra code by avoiding the extra overhead. but i may have to still go back and redo this in C. but there are somE ideas i have for changes that could be hard to do in C.
here is code i am currently thinking around
here is code i am currently thinking around
def nestloop(xlist,abc,sum,limit): xlist.append(0) for num in range(*abc): xlist[-1] = num u = sum+num if u==limit: print(' '.join([repr(x) for x in xlist])) # or do a yield of xlist here break if u>limit: break nestloop(xlist,abc,u,limit) xlist.pop(-1) return
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.