jtr@expya.UUCP (Jason Trenouth) (04/19/88)
In reply to Ian Dickenson's posed "quickie": exactly_one(X, Y) :- contains(X, Y), p(Y), bagof(Y1, ( contains(X, Y1), \+(Y1 = Y), % Assuming N unifications are better q(Y1) % than one call to "q". ), Ys). The algorithm computes at worst: N calls to "p" (where N is the number of Ys "contain"ed in X); and N*(N-1) calls to "q". By adding a lemma creation predicate (i.e. asserting) for "q" inside the "bagof" call we could achieve linearity in full calls to "q". [Anyone else?] Chow. _______________________________________ | | | Jason Trenouth | | Computer Science Department | | University of Exeter | | Devon EX4 4PT | | United Kingdom | | | | JANET: jtr@uk.ac.exeter.cs | | UUCP: jtr@expya.uucp | | BITNET: jtr%uk.ac.exeter.cs@ukacrl | |_____________________________________|