<repeat>
<repeat> is a General Operator
component that performs the requested operations in an iterative manner over the component specified (typically,
this is a list or an array). If the specified component is a <sequence>, a shorter method is to
use the <repeatForSequence> component.
The behavior of the <repeat> component is similar to a for loop in other programming languages.
Attributes and Properties
Attributes for <repeat>
Other (5)
asListboolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).
forgroup. The collection of items to iterate over when generating repeats.
indexNametext. Name to bind the current 1-based index to inside the repeat template.
typetext. Component type used to wrap each item in the source.
valueNametext. Name to bind the current item to inside the repeat template.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseWhether the generated repeats should be treated as responses for assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <repeat name="r">
Common to all components (3)
$r.doenetMLtext. The DoenetML source code that produced this component.
$r.hideboolean. Whether to hide this component from the rendered output.
$r.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: <repeat> a series of rectangles within a <graph>
A <repeat> can be used to generate multiple graphical elements at once when placed within a <graph>.
Example: <repeat> a user-specified number of inputs
A <repeat> can be used to generate a user-specified number of <mathInput> components.
For an alternative way to do this, see the <repeatForSequence> component.
Example: <repeat> a list of <text> elements
A <repeat> can be used with non-mathematical components as well. Individual
entries can be accessed using array notation.
Example: Use <repeat> in a combinatoric way
Use nested <repeat> components to iterate across all combinations of the specified components.
Example: Use <repeat> in a selective way
To achieve parallel iterative behavior, a combination of the indexName and valueName
attributes can be used.
Example: Generate a user-specified number of random <point> components
A <repeat> can be used to generate a user-specified number of randomly placed <point> components.
For an alternative way to do this, see the <repeatForSequence> component.