title: List of tuples to 2D array
body: <p>I would like to create a matrix from a given list of tuples.
  A tuple has <code>(row, column, value)</code> and I want to create <code>matrix[row][column] = value</code> with:</p>
  
  <pre><code>buildMatrix :: Int-&gt; [(Int, Int, Int)] -&gt; [[Int]]
  </code></pre>
  
  <p>For example, given:</p>
  
  <pre><code>n = 3 (size of matrix)
  list = [(1,2,1), (1,3,-1), (2,3,1)],
  </code></pre>
  
  <p>I would like to get</p>
  
  <pre><code>matrix = [[0,1,-1], [0,0,1], [0,0,0]]
  </code></pre>
  
  <p>What I tried so far: </p>
  
  <pre><code>buildMatrix n (i, j, v) = [ [ entry row column | column &lt;- [1..n] ] | row &lt;- [1..n] ]
      where
      entry x y
         | x == i &amp;&amp; y == j = v
         | otherwise = 0
  </code></pre>
  
  <p>I am stuck at applying the function for each tuple, I was thinking about using map.</p>