Merging Two Ordered List in Prolog Gain Infiniti

Merging Two Ordered List in Prolog



merge(X,[],X).
merge([],Y,Y).
merge([X|T],[Y|T1],[X|L]):-X<=Y,merge(T,[Y|T1],L).
merge([X|T],[Y|T1],[Y|L]):-X>Y,merge([X|T],T1,L).

OUTPUT:-

 merge([a,b],[b,c],L)
L=["a","b","b","c"]

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 

Design By Manish and Ranjan