Path: 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 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.