Article View: comp.lang.prolog
Article #2614Prolog (Turbo) Programming Question
From: kevin
Date: Sun, 29 Mar 1987 01:59
Date: Sun, 29 Mar 1987 01:59
53 lines
2100 bytes
2100 bytes
I am working my way through the Turbo Prolog tutorial, in attempt to learn
Prolog. By the way, does anyone have any good textbook suggestions for a
quick, advanced introduction to Prolog?
Anyway, I am stuck on the use of the cut. There is an exercise in the book
which requires the printing of a tournament between players. Each player
should only be occur once. Also, only those players in equal or lower
league may be challenged. See the book for further info. Somehow the
cut is supposed to be the solution, but I don't see it. The example
below is as close as I have come, but it doesn't work.
/* exercise 2, tutorial III */
domains
name=symbol
league=integer
predicates
tourney(name,name)
partner(name,league,name)
can_challenge (league,league)
player(name,league)
flag_end(name)
clauses
player(tom,3).
player(tim,3).
player(tut,3).
player(sue,2).
player(sam,2).
player(sis,2).
player(joe,1).
player(jim,1).
player(jed,1).
player(end,0).
can_challenge(P,Q) :- P >= Q.
tourney(X,Y) :- player(X,Xl),
partner(X,Xl,Y).
partner(X,Xl,Y) :-
player(Y,Yl),
X <> Y,
can_challenge(Xl,Yl),
flag_end(Y).
flag_end(P) :- P <> end,!.
Can anyone help me?
Kevin Buchs 3500 Zycad Dr. Oakdale, MN 55109 (612)779-5548
Zycad Corp. {rutgers,ihnp4,amdahl,umn-cs}!meccts!zeke!kevin
--
Kevin Buchs 3500 Zycad Dr. Oakdale, MN 55109 (612)779-5548
Zycad Corp. {rutgers,ihnp4,amdahl,umn-cs}!meccts!zeke!kevin
Technical Details
Message-ID:
<183@zeke.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!dayton!meccts!zeke!kevinShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!dayton!meccts!zeke!kevin From: kevin@zeke.UUCP Newsgroups: comp.lang.prolog Subject: Prolog (Turbo) Programming Question Message-ID: <183@zeke.UUCP> Date: Sat, 28-Mar-87 20:59:46 EST Article-I.D.: zeke.183 Posted: Sat Mar 28 20:59:46 1987 Date-Received: Sun, 29-Mar-87 17:18:13 EST Organization: ZYCAD, St. Paul, MN Lines: 53 Keywords: Prolog, Programming, Question, Turbo