title: Haskell Pattern Matching: Specifying the number of elements in a list
body: <p>So i am currently working with Haskell at my college, but kinda struggling with pattern-matching and to be more specific i'll give the program, that i am to solve:</p>
  
  <p>My function is awaiting a list of lists ( with each list containing at least 3 elements ) and in each list the second element is replaced with the number of the third element. </p>
  
  <p>Example: </p>
  
  <p><code>[[1,2,3],[4,5,6,7],[8,9,10]]</code> should become <code>[[1,3,3],[4,6,6,7],[8,10,10]</code></p>
  
  <p>So far I've made the following:</p>
  
  <pre><code> f [] = []
   f [[x]] = []
   f [[x,y]] = []
   f [[x,y,z]] = [[x,z,z]]
   f ([x,y,z]:xs) = [x,z,z]:f(xs)
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>How can i identify, that some lists may contain more than 3 elements and that the list must remain the same, only the 2nd element changes.</p></li>
  <li><p>How can i make the recursion, so that it handles exceptions (for example the first list has 4 elements).
  Thank you in advance!</p></li>
  </ol>