title: Exception error in Erlang
body: <p>So I've been using Erlang for the last eight hours, and I've spent two of those banging my head against the keyboard trying to figure out the exception error my console keeps returning.</p>
  
  <p>I'm writing a dice program to learn erlang. I want it to be able to call from the console through the erlang interpreter. The program accepts a number of dice, and is supposed to generate a list of values. Each value is supposed to be between one and six.</p>
  
  <p>I won't bore you with the dozens of individual micro-changes I made to try and fix the problem (random engineering) but I'll post my code and the error. </p>
  
  <p>The Source:</p>
  
  <pre><code>-module(dice2).
  -export([d6/1]).
  
  d6(1) -&gt;
      random:uniform(6);
  d6(Numdice) -&gt;
      Result = [],
      d6(Numdice, [Result]).
  
  d6(0, [Finalresult]) -&gt;
      {ok, [Finalresult]};
  
  d6(Numdice, [Result]) -&gt;
      d6(Numdice - 1, [random:uniform(6) | Result]).
  </code></pre>
  
  <hr>
  
  <p>When I run the program from my console like so...
  <code>dice2:d6(1).</code></p>
  
  <p>...I get a random number between one and six like expected.
  However when I run the same function with any number higher than one as an argument I get the following exception...</p>
  
  <blockquote>
    <p>**exception error: no function clause matching dice2:d6(1, [4|3])</p>
  </blockquote>
  
  <p>... I know I I don't have a function with matching arguments but I don't know how to write a function with variable arguments, and a variable <em>number</em> of arguments.</p>
  
  <p>I tried modifying the function in question like so....</p>
  
  <pre><code>d6(Numdice, [Result]) -&gt;
      Newresult = [random:uniform(6) | Result],
      d6(Numdice - 1, Newresult).
  </code></pre>
  
  <p>... but I got essentially the same error. Anyone know what is going on here?</p>