:- module(_,_).

% Types of cuts - White and Green Cuts
% ------------------------------------

% ------------------------------------
% White cuts - affect neither completeness nor correctness
% Can be used freely

% Example: 
white_max(X,Y,X) :-
    X > Y,
    !.
white_max(X,Y,Y) :-
    X =< Y.

% Try:
% ?- white_max(5,2,M).
% ?- white_max(2,5,M).
% ?- white_max(5,2,2).

% --------------------------------------
% Green cuts - affect completeness but not correctness correctness
% Can be used if we do not need all the solutions
% Necessary in some situations (but be careful!)

address(X,Add) :-
    home_address(X,Add), 
    !.
address(X,Add) :-
    business_address(X,Add).

home_address(john,pfluggerville).

business_address(john,austin).
business_address(mary,boston).

% Try (look for all solutions):
% ?- address(john,Add).
% ?- address(mary,Add).

member_normal(X,[X|_]).
member_normal(X,[_|T]) :-
    member_normal(X,T).

member_check(X,[X|_]) :- !.
member_check(X,[_|T]) :-
    member_check(X,T).

% Try (look for all solutions):
% ?- member_normal(X,[1,2,3,4]).
% ?- member_check(X,[1,2,3,4]).
% ?- member_normal(1,[1,2,1,4]), write('found solution'), nl, fail.
% ?- member_check(1,[1,2,1,4]), write('found solution'), nl, fail.
