title: How to check in the next 'head' in OCaml is empty?
body: <p>I'm new at OCaml (and still a novice in learning programming in general) and I have a quick question about checking what kind of string the next element in the string list is. </p>
  
  <p>I want it to put a separator between each element of the string (except for the last one), but I can't figure out how to make the program 'know' that the last element is the last element. </p>
  
  <p>Here is my code as it is now:</p>
  
  <pre><code>let rec join (separator: string) (l : string list) : string = 
   begin match l with
      | []-&gt;""
      | head::head2::list-&gt; if head2=[] then head^(join separator list) else head^separator^(join separator list)
   end
  
  
  let test () : bool =
   (join "," ["a";"b";"c"]) = "a,b,c"
  ;; run_test "test_join1" test 
  </code></pre>
  
  <p>Thanks in advance!</p>