% 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. % player_league(Player, League) player_league(ann, 3). player_league(joyce, 3). player_league(ramona, 2). player_league(cynthia, 2). player_league(susan, 1). player_league(lisa, 1). possible_game(Player1, Player2) :- player_league(Player1, League1), player_league(Player2, League2), Player1 @< Player2, % generate only canonical descriptions League1-League2 =< 1, % difference not too great one way League2-League1 =< 1. % difference not too great other way. % write_all_games :- % forall( possible_game(Player1, Player2) % , format('~w versus ~w.~n', [Player1,Player2]) % ).