for x in list_of_things: if all(b.test_belief(x) for b in list_of_formulae): do_something_with(x) break # if you only are looking for the first matching x
Hmmm, I don't know Java very well but doesn't it have the 'break' and 'continue' statements from C? If you have an outer loop over things and an inner one over formulae, then 'break' out of the inner one if a test returns false. After the inner loop, check if the last test was false or true, if false, then 'continue' to the next x.
Ah, reading your description, it looks like you have the outer loop over the tests and the inner loop over the things? Is that neccessary? If so you need to keep a list of things that have passed all the tests so far, which, for each test, you go through and remove those that fail the test. At the end you are left with a list of all the things that have passed all the tests. Java must have lists, doesn't it?
no subject
for x in list_of_things:
if all(b.test_belief(x) for b in list_of_formulae):
do_something_with(x)
break # if you only are looking for the first matching x
Hmmm, I don't know Java very well but doesn't it have the 'break' and 'continue' statements from C?
If you have an outer loop over things and an inner one over formulae, then 'break' out of the inner one
if a test returns false. After the inner loop, check if the last test was false or true, if false, then 'continue'
to the next x.
Ah, reading your description, it looks like you have the outer loop over the tests and the inner loop over the things? Is that neccessary? If so you need to keep a list of things that have passed all the tests so far, which, for each test, you go through and remove those that fail the test. At the end you are left with a list of all the things that have passed all the tests. Java must have lists, doesn't it?