First and last element of list OCaml
<p>I am trying to get first and last element of the list in OCaml. I expect that my function will be like</p>

<pre><code>'a list -&gt; 'a * 'a
</code></pre>

<p>What I am trying to do is </p>

<pre><code>let lista = [1;2;3;4;6;0];;

let rec first_last myList =
        match myList with
        [x] -&gt; (List.hd lista,x)
        | head::tail -&gt;     
                  first_last tail;;

first_last lista;;
</code></pre>

<p>Of course because of I made list as integer then I am doing this syntax like </p>

<pre><code>*int list -&gt; int * 'a
</code></pre>

<p>The point is that I dont have idea how to do this function for 'a.</p>

<p>Whats the direction?</p>