title: NetLogo: Refer to current item in 'foreach'
body: <p>Let's say I have</p>
  <pre><code>globals [x]
  patches-own [number]
  
  to set.x
    set x list 3 8
  end
  
  to set.number
    ask patches [
      set number random 10
    ]
  end
  </code></pre>
  <p>Let's say now I want each patch with <code>number</code> = 3 or <code>number</code> = 8 to change <code>number</code> to 0.</p>
  <p>I want to do it using <code>foreach</code>, but I am not understanding how I can use <code>foreach</code> to iterate through <code>x</code> <strong>and</strong>, while that happens, refer to the current value being used from <code>x</code>.</p>
  <p>Something like</p>
  <pre><code>to bring.to.zero
    foreach x ask patches with [number = *the current value from x*]
      [set number 0]
    ]
  end
  </code></pre>
  <p>I am very aware this last bit of code is not valid both in its syntax and in the fact that I don't know how to express that passage between asterisks; I cannot wrap my head around how to make it work.
  Perhaps I just do not use NetLogo enough, but the description of <code>foreach</code> from the NetLogo dictionary didn't help me either.</p>
  <p>Note that I solved the specific problem with a different approach:</p>
  <pre><code>to bring.to.zero
    ask patches [
      if member? number x [set number 0]
    ]
  end
  </code></pre>
  <p>But I am still curious as if and how it could be done with <code>foreach</code>.</p>