Write a Program in PROLOG to implement sublist(S, L) that checks whether the list S is the sublist of list L or not. (Check for sequence or the part in the same order).

20.Write a Program in PROLOG to implement sublist(S, L) that checks whether the list S is the sublist of list L or not. (Check for sequence or the part in the same order).

%Program in PROLOG to implement sublist(S, L)

%  below subset function is not predefined you can use any name as function

subset([], L).
subset([E|Tail], [E|NTail]):-
subset(Tail, NTail).
subset([E|Tail], [D|NTail]):-
subset([E|Tail], NTail).


% Output


No comments:

Post a Comment

Featured post

Amazon Interview Process

On July 5, 1994, Jeff Bezos started the world's most "customer-centric" firm out of his garage in Bellevue, Washington. The A...