title: prolog avg of list
body: <p>I have the code that able to calculate the avg of a list, but the only problem is it has error when it is empty list. I want to return false when the list is empty. any hint?</p>
  
  <pre><code>avg( List, Avg ):- 
      sum( List, Sum ),
      length( List, Length), 
      Avg is Sum / Length.
  </code></pre>