domains
name = symbol
namelist = name*
predicates
sublist(namelist,namelist)
clauses
sublist([],[]).
sublist([First|Rest],[First|Sub]):-
sublist(Rest,Sub).
sublist([_|Rest],Sub):-
sublist(Rest,Sub).
Output
Goal: sublist([a,x,y,b,c
d],[x,y])
Yes
Goal: sublist([a,x,y,b,c
d],[a,b])
Yes
Goal: sublist([a,x,y,b,c
d],[a,h])
No
Goal: sublist([a,b,c],X)
X=["a","b","c"]
X=["a","b"]
X=["a","c"]
X=["a"]
X=["b","c"]
X=["b"]
X=["c"]
X=[]
8 Solutions