title: List diagonals of a matrix in Prolog
body: <p>How could I get a list of the diagonals of a matrix of size <code>n*n</code> in Prolog?</p>
  
  <p>Expected behavior:</p>
  
  <pre><code>?- diagonal1([[1,3,2],[4,5,7],[6,8,9]],D1). 
  D1=[1,5,9]
  ?- diagonal2([[1,3,2],[4,5,7],[6,8,9]],D2). 
  D2=[2,5,6].
  </code></pre>
  
  <p>(I'm fine with using built-in functions.)</p>