Path: utzoo!mnetor!uunet!husc6!mailrus!ames!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!otter!sfk From: sfk@otter.hple.hp.com (Stephen Knight) Newsgroups: comp.lang.prolog Subject: Re: Programming Quickie Message-ID: <1600012@otter.hple.hp.com> Date: 28 Mar 88 13:03:51 GMT References: <1600011@otter.hple.hp.com> Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 22 Dear Ian, Here is my solution, which I submit for elegance points ... exactly_one( X, Y ) :- X contains Y, /* contains is infix in my version */ p( Y ), forall( ( X contains Y1, Y /= Y1 ), q( Y1 ) ). forall( X, Y ) :- not( (X, not(Y)) ). The inefficiency of this programs is the repeated calculation of q( Term ). One approach would be to patch this by making "q" cache, but other solutions on this problem are more efficient than that anyway. Steve Knight PS: I have tested this on some simple examples, although I could have introduced errors in transcribing it to this message.