How can I search whether there is an a in a list X such that there is a b later in the same list X such that the predicate p(a,b) returns explicitly true?
I.e. since p is a commutative function and potentially compute-intensive, if I have already called p(a,b), then I wish to avoid calling p(b,a).