title: Function that checks that list one is the beginning of list 2
body: <p>I'm trying to create a function that takes two lists and checks whether the first list is the start of the second list. I have the following pseudo code:</p>
  
  <ul>
  <li>an empty list starts a list</li>
  <li>a list does not start an empty list</li>
  <li>a list starts a second list if the they have the same head and tail of the second list</li>
  </ul>
  
  <p>Could someone please explain a good way to tackle this problem?</p>
  
  <p>for the first pseudocode statement I thought of doing something like:</p>
  
  <pre><code>fun starts [] l2 = false |
      starts l1 [] = false |
      starts l1 l2 = if ((hd(l1) = (hd(l2) andalso (tl(l1) = (tl(l2)) then true 
  </code></pre>
  
  <p>I'm not entirely sure whether this would work as what if the second lists tail is longer than the first lists tail? would an error occur? </p>
  
  <p>If someone could help explain or even find a solution, that would be great!</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>Found a way of doing it, I don't think I was too far off. </p>
  
  <pre><code>Fun start [] l2 = true |
  start l1 [] = false |
  start l1 l2 = if (hd(l1)) = (hd(l2)) then (start (tl(l1)) (tl(l2))) else false;
  </code></pre>