Hi, I would be grateful if anyone can give me any idea of solving this prolog problem
Here it is...
I would like to get the first two elements from a list and to check whether there's any repeated occurances in the list by comparing the two first elements and the rest of the list:
checking first two "a,b" in [a,b,c,d,e,d,a,b,e,a,a,b]
Moreover, i would like to have another list returned like this:
[[a,b],c,d,e,d,[a,b],e,a,[a,b]] which replaces all the occurances of "a,b" with [a,b]
I've tried using the built-in functions such as 'bagof' and 'member', however, they didn't make it work since they can only search a single element from a list. Can anyone think of any better implementations? Thanks.......
Here it is...
I would like to get the first two elements from a list and to check whether there's any repeated occurances in the list by comparing the two first elements and the rest of the list:
checking first two "a,b" in [a,b,c,d,e,d,a,b,e,a,a,b]
Moreover, i would like to have another list returned like this:
[[a,b],c,d,e,d,[a,b],e,a,[a,b]] which replaces all the occurances of "a,b" with [a,b]
I've tried using the built-in functions such as 'bagof' and 'member', however, they didn't make it work since they can only search a single element from a list. Can anyone think of any better implementations? Thanks.......