By alignment I mean that the predicate takes in two lists, well three with the alignment list. And then check that every item in the alignment list is indeed an element in both the other lits. And there is a requirement about order, so that rules out just checking that every item in the alignment list is a member of both the other input lits. If I just check for member, a valid alignment would also be valid when reversed. Which of course is wrong.
Example:
?- mxAli([4,2,9,8],[1,9,5,2,3,8],A).
A=[2,8] or A=[9,8]
8,2 and 8,9 is not valid here.
At once when I think about how to actually check the order my head goes back too imperative language programming. Any input is much appreciated. But don't give the answer straight out, I want hints on what I should read about. (I need to say this, because I get so good help at this site that it's close too cheating if I don't point this out).
My idea is that I , or prolog, needs to continue its search after the index of it's current element. That would make the reverse alignment not valid?
Edit: It would have to continue the search, after the current element's index in both the lists. As in the example above, when it finds the 2, it starts the search for the next element at index 2 and at index 5. (First element being 1)