Article View: comp.lang.prolog
Article #85Re: transitive and symetric relations
From: Paul Singleton
Date: Tue, 11 Aug 1992 15:11
Date: Tue, 11 Aug 1992 15:11
31 lines
1418 bytes
1418 bytes
From article <1992Aug11.131542.18608@dcs.qmw.ac.uk>, by mmh@cs.qmw.ac.uk (Matthew Huntbach):
[deleted]
> You need to represent your known distances as facts with a separate
> predicate:
>
> dist(a,b,4).
> dist(b,c,5). etc.
>
> Now have:
>
> distance(X,Y,D) :- dist(X,Y,D).
> distance(X,Y,D) :- dist(Y,X,D).
> distance(X,Y,D) :- dist(X,Z,D1),distance(Z,Y,D2),D is D1+D2.
I'm tempted (off the top of my head) to take this a stage further, and
have _three_ nested procedures:
outer one implements transitivity
middle one implements symmetry
innermost one has canonical data
Somehow it seems eleganter :) to implement these aspects separately.
If only because there are various ways to implement transitivity.
----
__ __ Paul Singleton (Mr) JANET: paul@uk.ac.keele.cs
|__) (__ Computer Science Dept. other: paul@cs.keele.ac.uk
| . __). Keele University, Newcastle, tel: +44 (0)782 621111 x7355
Staffs ST5 5BG, ENGLAND fax: +44 (0)782 713082
Technical Details
Message-ID:
<3762@keele.keele.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!keele!csa09References:
<1992Aug11.131542.18608@dcs.qmw.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!keele!csa09 From: csa09@seq1.keele.ac.uk (Paul Singleton) Newsgroups: comp.lang.prolog Subject: Re: transitive and symetric relations Message-ID: <3762@keele.keele.ac.uk> Date: 11 Aug 92 15:11:40 GMT References: <1992Aug11.131542.18608@dcs.qmw.ac.uk> Distribution: comp.lang.prolog Organization: University of Keele, England Lines: 31