title: Haskell: Splitting a list into 2 at index k
body: <p>I'm pretty new to Haskell, and I'm having a little trouble. I'm trying to implement a function that takes a list, and an int. the int is supposed to be the index k at which the list is split into a pair of lists. The first one containing the first k elements of the list, and the second from k+1 to the last element. Here's what I have so far:</p>
  
  <pre><code>split :: [a] -&gt; Int -&gt; ([a], [a])
  split [] k = error "Empty list!"
  split (x:[]) k = ([x],[])
  split xs k | k &gt;= (length xs) = error "Number out of range!"
             | k &lt; 0 = error "Number out of range!"
  </code></pre>
  
  <p>I can't actually figure out how to do the split. Any help would be appreciated.</p>