title: Get the last element of a list in f#
body: <p>I want to get the last element of a list and my logic is to reverse the list and to get its head:</p>
  
  <pre><code>module Program1 = 
  
      let last list =
          let newList=List.rev list;
          List.head newList;
          newList 
  
      let mainP1()=
          let list= [ 1; 2; 3] 
          printfn "Ultimul element al listei %A este %A" list (last list )
  </code></pre>
  
  <p>but it gives me this error</p>
  
  <pre><code>Error       Type mismatch. Expecting a
      unit list    
  but given a
      int list    
  The type 'unit' does not match the type 'int'   
  </code></pre>
  
  <p>Can anyone please help me?</p>