[Tutor] stopping a loop

Tim Peters tutor@python.org
Sat, 5 May 2001 19:55:11 -0400


[Julieta Rangel]
> ...
> Now I  have to check for associativity, and I'm trying to figure out
> how I can do that.
> ...
> we can look for associativity by making all the possible combinations.
> That is, verify that e*(e*e)=(e*e)*e, a*(e*e)=(a*e)*e, and so on.

Here's a hint:  you want to verify that x*(y*z) == (x*y)*z for all x, y and z
in your set.  Earlier you wanted to build a table for all x and y in your
set.  The latter involved two variables and was solved with a doubly-nested
loop.  So the former, involving three variables, might be approached how?

One more hint:  If x, y and z are elements of your set, then the result of
x*(y*z) is spelled how?  Start with y*z:  that's

    product[y, z]

So x*(y*z) is

    product[x, product[y, z]]

and (x*y)*z is ...?

you're-closer-than-you-know<wink>-ly y'rs  - tim