invalid6363
Programmer
i'm trying to write a predicate that takes a list and a pattern and determines if the pattern exists in the list.
for example:
list = [r,r,b,g,y]
pattern = r,r
occurs([X,Y|_],X,Y).
occurs([_|L],X,Y) :- occurs(L,X,Y).
this kind of works for a pattern of two, but if the pattern is r,b the result would be false.
any suggestions on how to fix this would be greatly appreciated.
thank you.
for example:
list = [r,r,b,g,y]
pattern = r,r
occurs([X,Y|_],X,Y).
occurs([_|L],X,Y) :- occurs(L,X,Y).
this kind of works for a pattern of two, but if the pattern is r,b the result would be false.
any suggestions on how to fix this would be greatly appreciated.
thank you.