title: Prolog iterating over list
body: <p>I am working with Prolog sample list programs and triying to do some operations on them. However, I am stuck at a point and couldn't find any solution or sample. </p>
  
  <p>I want to write a function which takes two lists of integers and return a float value. The two lists size are equal. The float value is the result of comparison divided by list size.</p>
  
  <p>The function should compare every elemen of first list to every elemen of the second list. A pair (i, j) is that i is the location of element in first list and j is the location of the element in second list. If element i greater than element j, result of comparison is incremented by 1. If element i less than element j, result of comparison decremented by 1. If equal, nothing happen. At the end of the above operation, we return the float value described above.</p>
  
  <p>Example:</p>
  
  <pre><code>retVal([4,5,3], [8,2,1], Result).
  </code></pre>
  
  <p>should return Result = (-1+1+1-1+1+1-1+1+1) / 3 = 0.33</p>
  
  <p>In object oriented language, it is as simple as printing something on the console. However, I don't have any idea in Prolog. Thank you in advance.</p>