ForEach and Values

ForEach is a function that takes one argument, an iterator. It calls next() on the iterator a certain number of times, given by its begin and end arguments. As do all functions, it returns its result as a Value object.

In the next example, forEach calls list.next() 5 times. The result of each call is a Value object that contains a Values (a ValuesValue).

    
    <dmf:forEach id="iter" begin="1" end="5">
      <dm:list id="list">
	<dm:ints range="[0]"/>
	<dm:ints range="[100]"/>
      </dm:list>
    </dmf:forEach>
    
  

If iter were called twice and the result printed, it would look like:

    [[0, 100], [1, 101], [2, 102], [3, 103], [4, 104]]
    [[5, 105], [6, 106], [7, 107], [8, 108], [9, 109]]
  

Each line is the return value from one call to forEach. Note that it is a single object (enclosed in brackets), that contains 5 objects (each enclosed in brackets).