title: NetLogo: the meaning of TO-REPORT explained for dummies?
body: <p>I have a problem to understand the role of <code>to-report</code> and <code>report</code> in NetLogo, even it seems pretty useful and I can't really find a help written in "human style" language. </p>
  
  <p>In NetLogo dictionnary <a href="http://ccl.northwestern.edu/netlogo/docs/dictionary.html#report" rel="noreferrer">http://ccl.northwestern.edu/netlogo/docs/dictionary.html#report</a>  I can find definitions for <code>to-report</code> : </p>
  
  <pre><code>to-report procedure-name
  to-report procedure-name [input1 ...]
  Used to begin a reporter procedure.
  
  The body of the procedure should use report to report a value for the procedure. See report. 
  </code></pre>
  
  <p>and for <code>report</code>: </p>
  
  <pre><code>report value
  Immediately exits from the current to-report procedure and reports value as the result of that procedure. report and to-report are always used in conjunction with each other. See to-report for a discussion of how to use them.
  </code></pre>
  
  <p>So, it seems <code>to-report</code> and <code>report</code>  calculate some value and report it. </p>
  
  <p>Thus, when I try add </p>
  
  <pre><code>to-report average [a b c]
    report (a + b + c) / 2
  end
  </code></pre>
  
  <p>to my code, and then use the <code>average</code> variable somewhere in my code p.e.:</p>
  
  <pre><code>to go 
    ...
    print average 
    tick
  end
  </code></pre>
  
  <p>I've got an error: <code>AVERAGE expected 3 inputs</code>. When I try to create my variables [a b c] in <code>globals [a b c]</code> I've got an error <code>There is already a global variable called A</code>. 
  If I define my variables <code>[a b c]</code> within <code>to-report</code> procedure:</p>
  
  <pre><code>to-report average [a b c]
      set a 1
    set b 2
    set c 3
    report (a + b + c) / 2
  end
  </code></pre>
  
  <p>My error is again <code>AVERAGE expected 3 inputs</code>. </p>
  
  <p>Thus, <strong>how can I simply test the usefulness of to-report procedure? And where to place it correctly in my code to see what it is really doing?</strong> From Urban Suite - Economic Disparity  (<a href="http://ccl.northwestern.edu/netlogo/models/UrbanSuite-EconomicDisparity" rel="noreferrer">http://ccl.northwestern.edu/netlogo/models/UrbanSuite-EconomicDisparity</a>) I see that to-report is used to calculate values related to each patch: </p>
  
  <pre><code>to-report patch-utility-for-poor
      report ( ( 1 / (sddist / 100 + 0.1) ) ^ ( 1 - poor-price-priority ) ) * ( ( 1 / price ) ^ ( 1 + poor-price-priority ) )
  end
  </code></pre>
  
  <p>however this reported value is not directly defined as patch variable which increase my confusion... </p>
  
  <p><a href="https://i.stack.imgur.com/xpIHV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xpIHV.png" alt="enter image description here"></a></p>
  
  <p>Thank you ! </p>