Prolog predicate that returns a list after checking for element -


i new prolog. trying write predicate accepts element , list , checks see occurrence of element in list , returns rest of list after element.
example mypredicate(3, [1 2, 3, 4, 5, 6, 7]) returns [3, 4, 5, 6, 7].
hope able explain.

mypredicate(x, [x|_]). mypredicate(x, [_|t]) :- mypredicate(x,t). 

this checking if element there in list. how write rule returns rest of list after x?

you need return list in base case like:

mypredicate(x, [x|t],[x|t]). 

also clause:

 mypredicate(x, [_|t]) :- mypredicate(x,t). 

is used when head of list x, need make sure in case head different x like:

mypredicate(x, [h|t],l) :- dif(x,h),mypredicate(x,t). 

Comments