title: Learning Haskell: How to implement my own version of init function
body: <p>As part of learning Haskell, I am trying to implement my own version of various functions associated with Lists. Right now I am stuck on the <strong>init</strong> function. init function in Haskell returns all the elements in a List other than the last element. </p>
  
  <p>Here is what I have done so far.</p>
  
  <pre><code>init' :: [Int] -&gt; [Int]
  init' [] = error "This function cannot be applied to an empty list"
  init' [x] = [x]
  init' (x:xs) = x : init' xs
  </code></pre>