title: Prolog query to find largest element in database?
body: <p>If I have defined all the digits in a Prolog database, such as <code>dig(0), dig(1), ..., dig(9)</code>. What query can I use for Prolog to return the largest digit -- in this case, 9?</p>
  
  <p>I tried something like:</p>
  
  <pre><code>?- dig(N), dig(M), N &gt; M.
  </code></pre>
  
  <p>But that just returns the first possibility, not the largest number.</p>