:- set_prolog_flag( discontiguous_warnings,off ).
:- set_prolog_flag( single_var_warnings,off ).
:- set_prolog_flag( unknown,fail ).



%i
soma(X,Y,R):- R is X+Y.
%ii

operacao(X,Y,O,R):- O=soma, R is X+Y.
operacao(X,Y,O,R):- O=multipli, R is X*Y.
operacao(X,Y,O,R):- O=divide, R is X/Y.
operacao(X,Y,O,R):- O=subtrair, R is X-Y.

%iii
soma3(X,Y,K,R):- R is X+Y+K.

%IV

somaconjunto([],0).
somaconjunto( [H|T],R ) :-
somaconjunto( T,R1 ),
R is H+R1.

%maior conjunto valores

maior([],0).

maior1(P,J,R):- P < J , R is J.
maior1(P,J,R):- P > J, R is P.
maior([H|T],R):- maior(T,K), maior1(H,K,R).

% pertence

pertence(X,[X]).
pertence(X,[X|Y]).
pertence(X,[Y|X]).
pertence(X,[K|Y]):-pertence(X,Y).

%elementos

comprimento([],0).
comprimento([X|L],N) :-
comprimento(L,M),
N is M+1.

%apagar

apagar(X, [X|Y], Y).
apagar(X,[K|Y],[K|H]):- pertence(X,Y), apagar(X,Y,H).

%apagartudo

apagartudo(


