ReferencerepeatForSequence

<repeatForSequence>

Repeats template content for each value in an arithmetic sequence

<repeatForSequence> is a General Operator component that performs the requested operations in an iterative manner over the sequence specified. Its behavior is similar to a for loop in other programming languages.


Attributes and Properties

Attributes for <repeatForSequence>

Other (9)
asList

boolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).

exclude

_componentListWithSelectableType. Values to exclude from the sequence.

from

_componentWithSelectableType. The first value in the sequence.

indexName

text. Name to bind the current 1-based index to inside the repeat template.

length

integer. The number of values in the sequence.

step

math. The increment between successive values in the sequence.

to

_componentWithSelectableType. The last value in the sequence. Used together with from to determine length when length is not specified.

type

keyword. The kind of values in the sequence.

ValueDescription
numberA sequence of numeric values.
mathA sequence of math expressions (allows symbolic from/to/step).
lettersA sequence of letters (single-letter or multi-letter labels).
valueName

text. Name to bind the current item to inside the repeat template.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

Whether the generated repeats should be treated as responses for assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <repeatForSequence name="r">

Common to all components (3)
$r.doenetML

text. The DoenetML source code that produced this component.

$r.hide

boolean. Whether to hide this component from the rendered output.

$r.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: <repeatForSequence> a set of points within a <graph>

A <repeatForSequence> can be used to generate multiple graphical elements at once when placed within a <graph>.


Example: <repeatForSequence> a user-specified number of inputs

A <repeatForSequence> can be used to generate a user-specified number of <mathInput> components.

The <repeatForSequence> component generates an array. Individual entries can be accessed using array notation.


Example: Nested <repeatForSequence> to generate an irregular grid

A <repeatForSequence> can be nested within another <repeatForSequence> to iterate over a combination of sequences with different ranges and steps.


Example: Generate a user-specified number of random <point> components

A <repeatForSequence> can be used to generate a user-specified number of randomly placed <point> components.