title: New to OCaml finding index of element in a list
body: <p>I am learning OCaml and one of my practice problems I've given myself is to find the index of an element in a created list. So far I thought I had it but I've been rewriting this code block for ages and can't seem to get why the return values are incorrect. </p>
  
  <pre><code>let rec indexer_helper list element index pos found= 
  match l with 
          []      -&gt;  if (found = false) then
                          (-1)
                      else
                          index
  
      |   (h::t)  -&gt;  if (h = e) then
                          index = pos
                          pos = pos + 1
                          indexer_helper t element index pos true
                      else
                          pos = pos + 1
                          indexer_helper t element index pos found;;
  
  let rec indexer list element = indexer_helper list element 0 0 false;;
  </code></pre>
  
  <p><strong>Edit</strong>: Problem solved. Issue was I forgot to use let statements when "changing" the immutable variables.</p>