🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1019

Having a problem understanding the cut (arrgh!)

#1019
From: F0O
Date: Thu, 26 Jul 1990 13:05
59 lines
1648 bytes
I'm just a beginning prolog programmer, and was trying an exercise
in a book on using the cut.  Below is a description of the problem:

Players in a squash club are divided into three leagues, and players
may only challenge members in their own league or the league below,
if there is one.

Write a prolog program that will display all possible matches between
club players in the form:

tom versus bill

Use the cut to ensure for example, that
Tom versus bill
and
bill versus tom

are not both displayed.
END OF PROBLEM DESCRIPTION

Below is the program I wrote in PDC prolog on an ibm pc.  PDC prolog
used to be Turbo Prolog.
I may have wrote the problem wrong, but putting the cut after
the first member subgoal will on show all players ann can play.
Putting the cut after the second member subgoal will only show one
person ann can play.

Where have I gone astray?

[Tim]




PROGRAM in PDC prolog:

domains
player = symbol
league = integer

predicates
member(player,league)
match

clauses
member(ann, 3).
member(joyce, 3).
member(ramona, 2).
member(cynthia, 2).
member(susan, 1).
member(lisa, 1).

match :-
member(Player1, Level1),
member(Player2, Level2),
Player1 <> Player2,
Level1 >= Level2,
write(Player1, " versus ",Player2), nl, fail.
Technical Details
Message-ID: <90207.090559F0O@psuvm.psu.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!hellgate.utah.edu!hamblin.byu.edu!byuvax!byuvm!cunyvm!psuvm!f0o

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!hellgate.utah.edu!hamblin.byu.edu!byuvax!byuvm!cunyvm!psuvm!f0o
From: F0O@psuvm.psu.edu
Newsgroups: comp.lang.prolog
Subject: Having a problem understanding the cut (arrgh!)
Message-ID: <90207.090559F0O@psuvm.psu.edu>
Date: 26 Jul 90 13:05:59 GMT
Organization: Penn State University
Lines: 59