title: Best way to split several heads from a list with Erlang?
body: <p>So, Erlang is a real joy to work with, but there's one problem I run into occasionally, that I'm wondering if there is a nicer way to solve. Often, I find myself needing to split several items from a list. The syntax for splitting a list into a Head and Tail is straight forward enough, but what about when there are multiple items.</p>
  
  <pre><code>1&gt; List = [1,2,3,4,5].
  [1,2,3,4,5]
  2&gt; [Head | Tail] = List.
  [1,2,3,4,5]
  3&gt; Head.
  1
  4&gt; Tail.
  [2,3,4,5]
  </code></pre>
  
  <p>Is there a nicer way to get, say, the first two elements of a list other than splitting twice inline?</p>
  
  <pre><code>1&gt; List = [1,2,3,4,5].
  [1,2,3,4,5]
  2&gt; [Head1 | [Head2 | Tail]] = List.
  [1,2,3,4,5]
  3&gt; Head1.
  1
  4&gt; Head2.
  2
  5&gt; Tail.
  [3,4,5]
  </code></pre>
  
  <p>I know that this can also be simplified by writing functions that recursively split subsequent heads from a list, but I'm wondering if there is a simpler inline way to do it (or if in fact, the recursive subsequent split functions are the best practices way to accomplish this task)? Thanks!</p>