In article <[EMAIL PROTECTED]>, Dan Bishop <[EMAIL PROTECTED]> wrote: >Cameron Laird wrote: >... >> for hextuple in [(i, j, k, l, m, n) >> for i in range(1, lim + 1) \ >> for j in range (1, lim + 2) \ >> for k in range (1, lim + 3) \ >> for l in range (1, lim + 4) \ >> for m in range (1, lim + 5) \ >> for n in range (1, lim + 6)]: >> print hextuple >> >> I don't think the list comprehension helps, in this case--although >> it hints at the temptation of an eval-able expression which is >> briefer. More on that, later. > >from the recent "N-uples from list of lists" thread import cross > >for hextuple in cross(*[xrange(1, lim+p) for p in xrange(1, 7)]): > print hextuple >
Tangential remarks: cross product is *very* important; why isn't it built in? Yes, I recognize that the recipes supplied elsewhere are quite nice. I've seen a lot of Fortran and C code of the "for (...) {for (...) { ..." variety. I have a deep suspicion that most of them betray fundamental miscomprehension of physical realities. It's very, *very* unusual for any meaningful measurement to arise across a medium-dimension product of real intervals. I invite counterexamples. In the meantime, I'll persist in suspecting that such computations are symptoms of a misunderstanding. So: cross products are valuable, but particularly so when not limited to crosses over numeric intervals. -- http://mail.python.org/mailman/listinfo/python-list