Re: pldoc: how to specify predicates with arguments unbound.
Kuniaki Mukai <[email protected]> Wed, 17 Sep 2014 17:30:55 +0900
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On Sep 17, 2014, at 12:51, Richard A. O'Keefe <[email protected]> wrote: > > On 16/09/2014, at 5:57 PM, Kuniaki Mukai wrote: > >> >> Hi, >> >> Using pldoc, how do we specify a predicate such as follows: >> >> foo(X, Y) :- (random(3) =:= 2, X==Y; true). > > This is logically equivalent to foo(_, _). > Did you mean > > foo(X, Y) :- ( random(3) =:= 2 -> X == Y ; true ). > ^^ What I intended to write is the following: foo(X, Y) :- (random(3) =:= 2, X=Y; true), !. ?- foo(X, Y), X==Y. %@ X = Y . ?- foo(X, Y), X==Y. %@ false. ?- foo(X, Y), X==Y. %@ X = Y . I wrote a unifier on rational trees on Edinburgh Prolog in ancient time writing clauses for unbound arguments to test whether two variables are already unified or not. I am afraid that such kind of prolog programming is no more recommended nowadays from view of mode declaration. Thank you for pointing my careless typo. Kuniaki Mukai > > > _______________________________________________ > SWI-Prolog mailing list > [email protected] > https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 496 bytes Desc: Message signed with OpenPGP using GPGMail URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20140917/cbeac09e/signature.asc>