Pretty new to PROLOG, and i'm having a problem with this list.
I need a predicate (sublist(X,Y
) that is true if list X
is a sublist of list Y
. The sublist is the original list, in the same order, yet some elements may have been removed. For instance, some sample user input is:
?- sublist([a,b],[a,e,b,d,s,e]).
Yes
?- sublist([a,b],[a,e,e,f]).
No
?- sublist([a,b],[b,a]).
No
?- sublist(X,[a,b,c]).
X = [] ;
X = [a] ;
X = [a, b] ;
X = [a, b, c] ;
X = [a, c] ;
X = [b] ;
X = [b, c] ;
X = [c] ;
No