% ========Elemendi eemaldamine listist=========
% Test: remove(ats,[reet,pets, ott, ats,ats], Uus_list).
% Test: remove(mats,[reet,pets, ott, ats,ats], Uus_list).
%------------------------Versioon 1----------------------------
  remove(S, [S|T], L):- remove(S,T,L),!.
 % remove(S, [S|T], T).
  remove(S, [U|T], [U|L]):- remove(S,T,L).

%------------------------Versioon 2----------------------------
  remove(_,[],[]).
  remove(El,[El|List],List1):-
	remove(El,List,List1).
  remove(El,[El1|List],[El1|List1]):-
	remove(El,List,List1).

% ======== Korduvate elementide eemaldamine listist =====
% Päring:  remove_dups([s,d,f,g,h,s,d],L_out).
%-------------------------------------------------------------------------
  remove_dups([],[]).
  remove_dups([El|L_in],[El|L_out]):-
	remove_dups(L_in,L_out1),!,
	remove(El,L_out1,L_out).

%-------------------------------------------------------------------
% Elemendi sisalduvus listis, analoog member(El, List)
% TEST: l_inclusion(d,[f,s,e,d,a]).
%-------------------------------------------------------------------
  l_inclusion(El,[]):- fail.
  l_inclusion(El,[El|_]).
  l_inclusion(El,[El1|List]):- !,
	l_inclusion(El,List).

%--------------------------------------
% Kahe listi konkatenatsioon
% TEST: join([s,d,f,g],[2,w,3,4,3],LL).
% Analoog append/3
%---------------------------------------
  join([], A, A).
  join([A|B], C, [A|D]) :-
        join(B, C, D).

