Académique Documents
Professionnel Documents
Culture Documents
it21398
2.1
)
)
2.2
%boithitikes synartiseis
includes([X|T], X).
includes([H|T], X) :- includes(T,X).
male(X) :- family(X,_,_).
) ancestor(X,Y,1) :- parent(X,Y).
ancestor(X,Y,K) :- parent(X,Z), ancestor(Z,Y,KK), K is KK+1.
) rel(X,Y,K) :- ancestor(X,Y,K).
rel(X,Y,K) :- ancestor(Y,X,K).
rel(X,Y,K) :- ancestor(Z,X,K1), male(Z), ancestor(Z,Y,K2), X\=Y, K is K1+K2, KK is K-2,
not(rel(X,Y,KK)).
2.3
)is_list([_;_]).
is_list([]).
append([],X,X).
append([X;X1],Y,[X;X2]) :- append(X1,Y,X2).
)ins(Element,List,Nth,Result) :-
length([_|L0],Nth),
append(L0,[_|R],List),
append(L0,[Element|R],Result).