Herşey ilk adımlarla başlar...

Monday, January 26, 2009

Prolog Examples

1/26/2009 Posted by Nurettin Onur YAKIT No comments
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].



0 comments: