Skip to content

Iterators

An <iterator> names a sequence of propositions that a plan can consume one at a time.

<iterator name="room_iterator">
  <enumerate randomize="false" limit="5">
    <proposition predicate="room_type" value="single"/>
    <proposition predicate="room_type" value="double"/>
  </enumerate>
</iterator>

name is required. Exactly one enumerate child supplies propositions; randomize changes their order and limit restricts the number used. iterate consumes the next proposition, and has_more_items tests whether the iterator has values remaining.

For example, to visit at most two propositions in randomized order:

<iterator name="suggested_activity">
  <enumerate randomize="true" limit="2">
    <proposition predicate="activity" value="walk"/>
    <proposition predicate="activity" value="museum"/>
    <proposition predicate="activity" value="concert"/>
  </enumerate>
</iterator>

The iterator is exhausted after the configured values have been consumed. After exhaustion, another iteration begins at the start of the sequence. Use has_more_items in the current pass to exit or branch before that restart.

See Domain queries for predicate-based enumerations.