title: Prolog - first list is sublist of second list while maintaining order?
body: <p>I want to check if elements of list L1 occur consecutively, and in the same order, in list L2.</p>
  
  <p>For example - check([b,c],[a,b,c,d]) must return true while check([b,d],[a,b,c,d]) must return false</p>
  
  <p>I looked at similar posts <a href="https://stackoverflow.com/questions/7051400/prolog-first-list-is-sublist-of-second-list">Prolog - first list is sublist of second list?</a> and also tried out similar solutions but whenever i try to check if elements are present, i am unable to check if ordering is consecutive</p>
  
  <pre><code>check( [], _ ).
  check( [X|XS], [X|XSS] ) :- sublist( XS, XSS ).
  check( [X|XS], [_|XSS] ) :- sublist( [X|XS], XSS ).
  </code></pre>
  
  <p>and if i try to check if ordering is correct then my code is breaking.</p>
  
  <pre><code>check( [], _ ).
  check( [X|XS], [X|XSS] ) :- sublist( XS, XSS ).
  </code></pre>