[Baypiggies] Question about breaking out of a loop

Hy Carrinski hcarrinski at gmail.com
Tue Jun 7 21:40:09 CEST 2011

I am working on code to solve a combinatorial probability problem, and
plan to send a link to the full code in a few days.

There is generator that yields tuples in a defined order into a loop
that performs a calculation. I would like to provide an option to stop
the calculation when the threshold is reached.

I have put a simplified sample of this on github:

My questions are:
   1. Is it an antipattern to change a datatype to cause an exception?
   2. If so, how would you improve on my version 3 function?

The function in version 3 is pretty close to my current solution, but
the functions combinations(), f() and g() are standing in for more
computationally intensive functions. The potential antipattern
involves temporarily setting a value to None in a dictionary of

Thank you,

More information about the Baypiggies mailing list