title: Poly/ML Exception Cast "toAddress" raised
body: <p>Using Poly/ML, I wanted to write a function to construct an n*n identity matrix using Array of Arrays.</p>
  
  <p>I wrote:</p>
  
  <pre><code>fun equiv x y = if x = y then 1 else 0;
  fun idmatrix n = Array.tabulate(n, fn i =&gt; (Array.tabulate(n, equiv i)));
  </code></pre>
  
  <p>and it compiled successfully, giving</p>
  
  <pre><code>&gt; val equiv = fn: ''a -&gt; ''a -&gt; int
  &gt; val idmatrix = fn: int -&gt; int array array
  </code></pre>
  
  <p>But when I called <em>idmatrix</em></p>
  
  <pre><code>idmatrix 2;
  </code></pre>
  
  <p>for a test, the output of the compiler was</p>
  
  <pre><code>&gt; Exception- Cast "toAddress" raised
  </code></pre>
  
  <p>Can anybody explain why the exception was raised, please?</p>
  
  <p>Thank you very much!</p>