Basic Prolog Functions
1. Append
append([],Q,Q):-!.
append([H|T], Q, [H|T1]):- append(T, Q, T1).
2. Member
member(H,[H|T]):-!.
member(X, [H|T]):- member(X,T).
3. Intersect
intersect ([], L, []) :-!.
intersect ([H|T], L, L2):- member(H, L), intersect(T, L, L3), L2 = [H|L3], ! ;
intersect (T, L, L2).
4. Deletion
delete(X, [X], []) :- !.
delete(X, [X|T], T) :- !.
delete(X, [H|T], L) :- delete(X, T, L1), L=[H|L1].
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment