title: Identify whether an object comes before another object in a list
body: <p>I have this clause that says an object is directly before another object in the list. I'm looking for guidance on how to generalize this to be an object that is any location before the object in the list (not necessarily to the left of it immediately). Then I want to be able to also check for after as well.</p>
  
  <pre><code>% Checks that `X` comes before `Y`
  % in the list `Ds`
  before(X,Y,Ds) :-
      remainder(X,Ds,Rs),
      member(Y,Rs).
  
  % Finds a member of a list and
  % unifies the third parameter such
  % that it is the remaining elements in
  % the list after the found member
  remainder(X,[X|Ds],Ds).
  remainder(X,[_|Ds],Rs) :- remainder(X,Ds,Rs).
  </code></pre>