home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!agate!doc.ic.ac.uk!uknet!edcastle!aiai!ken
- From: ken@aiai.ed.ac.uk (Ken Johnson)
- Newsgroups: comp.lang.prolog
- Subject: Re: Help: making a binary predicate reversibly equal
- Message-ID: <8252@skye.ed.ac.uk>
- Date: 26 Jan 93 11:08:38 GMT
- References: <C1C63u.J6n@watserv1.uwaterloo.ca>
- Sender: news@aiai.ed.ac.uk
- Followup-To: comp.lang.prolog
- Organization: William's Wonderful Wonky Widget Warehouse
- Lines: 45
-
-
- In article <C1C63u.J6n@watserv1.uwaterloo.ca> jssloka@monet.uwaterloo.ca
- (Scott Sloka) writes:
-
- # I have a list of facts such as: nextto(a,b) and I would like nextto(a,b)
- # to be equivalent to nextto(b,a).
-
-
- This is a common problem. The usual solution is
-
- next_to(A,B) :-
- next_to_fact(A,B).
-
- next_to(A,B) :-
- next_to_fact(B,A).
-
-
- next_to_fact(e,r).
- next_to_fact(i,o).
- next_to_fact(o,p).
- next_to_fact(q,w).
- next_to_fact(r,t).
- next_to_fact(t,y).
- next_to_fact(u,i).
- next_to_fact(w,e).
- next_to_fact(y,u)
-
-
- Example run
-
- | ?- next_to(q,w).
-
- yes
- | ?- next_to(w,q).
-
- yes
- | ?- next_to(a,b).
- no
-
-
- --
- Son, all the pretty, intelligent, healthy # I have discovered of this
- young women are taken. It's a basic rule of # basic rule of the universe
- the universe, and if you don't like it, go # a most remarkable proof,
- somewhere else. -- my dad 1906-1992 # which this .signature is too
-