🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #2420

Re: Help: making a binary predicate reversibly equal

#2420
From: Ken Johnson
Date: Tue, 26 Jan 1993 11:08
45 lines
1403 bytes
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
Technical Details
Message-ID: <8252@skye.ed.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!agate!doc.ic.ac.uk!uknet!edcastle!aiai!ken
References: <C1C63u.J6n@watserv1.uwaterloo.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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