Skip to Content
ReferencemathList

<mathList>

A list of math expressions

<mathList> is a Math component that defines a list of math expressions, each like a <math>. Some components that accept a <mathList> as an input include functions, repeats, and awards.

When creating a <mathList>, separate items by spaces, not commas. The component will default to displaying the list with commas.

A comma between entries inside a <mathList> creates a tuple — a single math — so <mathList>x, y, z</mathList> is a list with the single entry (x,y,z), while <mathList>x y z</mathList> is a list of three entries. To split a math that already contains commas into separate entries, use the mergeMathLists attribute.

Attributes and Properties

Attributes for <mathList>

Highlighted (1)
asList

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

Number display (5)
avoidScientificNotationAdded in 0.7.16

boolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.

displayDecimals

integer. Default value: 2. Number of decimal places to display when rendering this number.

displayDigits

integer. Default value: 3. Number of significant digits to display when rendering this number.

displaySmallAsZero

number. Default value: 1e-14. Threshold below which numbers are displayed as zero.

padZeros

boolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Other (7)
functionSymbols

textList. Default value: ["f","g"]. Symbols treated as function names when parsing items.

number. Default value: Infinity. Maximum number of items to retain in the list.

boolean. Whether nested math-list children should be flattened into this list.

parseScientificNotation

boolean. Default value: false. Whether to parse expressions like 1e3 as scientific notation.

referencesAreFunctionSymbols

reference. References whose names should be treated as function symbols when parsing items.

splitSymbols

boolean. Default value: true. Whether multi-character symbols are split into a product of variables.

boolean. Default value: false. Whether the order of items in this list should be treated as unordered (e.g. for matching).

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

boolean. Default value: false. Whether this component is treated as a response for the purposes of 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 <mathList name="m">

Number display (5)
$m.avoidScientificNotationIn development

boolean. Whether to render numbers in full decimal form rather than scientific notation.

$m.displayDecimalsIn development

integer. Number of decimal places to display when rendering this number.

$m.displayDigitsIn development

integer. Number of significant digits to display when rendering this number.

$m.displaySmallAsZeroIn development

number. Threshold below which numbers are displayed as zero.

$m.padZerosIn development

boolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Other (8)
$m.functionSymbols

textList. Symbols treated as function names when parsing items.

$m.maxNumber

number. Maximum number of items to retain in the list.

$m.mergeMathLists

boolean. Whether nested math lists are merged into the parent list.

number. The number of items in the list.

$m.numValues

number. The number of values in the list.

$m.parseScientificNotation

boolean. Whether to parse expressions like 1e3 as scientific notation.

$m.splitSymbols

boolean. Whether multi-character symbols are split into a product of variables.

$m.unordered

boolean. Whether the order of items in this list should be treated as unordered (e.g. for matching).

Common to all components (8)
$m.disabledIn development

boolean. Whether this component is disabled and cannot be interacted with.

$m.doenetML

text. The DoenetML source code that produced this component.

$m.fixedIn development

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

$m.fixLocationIn development

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

$m.hiddenIn development

boolean. Whether this component is hidden from the rendered output.

$m.hide

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

$m.isResponseIn development

boolean. Whether this component is treated as a response for the purposes of assessment.

$m.styleNumber

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

Examples

Example: Defining a <mathList> and retrieving a value

The <mathList> component stores a list of math expressions. To access an individual element in the list, use array notation with the named <mathList>.


Example: A <mathList> from multiple <mathInput/> tags

Combining a number of user-inputs into a <mathList> is a simple matter of listing the named input references between the opening and closing tags.


Example: A <mathList> for function evaluation

Here, a <mathList> stores multiple input values to be used in the subsequent code for function evaluation.


Example: A <mathList> in a <repeat>

Here, a <mathList> is referenced within the for attribute of a <repeat>.


Example: A <mathList> in an <award>

A <mathList> is frequently used in an <award> to compare two groups of values. Comparisons can be ordered or unordered. (Also, specifying whether comparisons are to be ordered can occur in the <award>, the <answer>, or the <mathList> itself.)

Attribute Examples

Attribute Example: unordered

If a <mathList> is defined with the unordered attribute, comparisons (for validation in an <award> or a <boolean> for example) are unordered automatically.


Attribute Example: maxNumber

The maxNumber attribute imposes a limit on the number of maths that can be stored in the list.


Attribute Example: mergeMathLists

If individual maths contained within a <mathList> contain multiple values, those groupings will be preserved by default. To turn off this default behavior, use the mergeMathLists attribute.


Attribute Example: Attributes as properties

All of the attributes of the <mathList> component are also available as properties.

Property Examples

Property Example: numComponents

The numComponents property returns the number of items stored in a <mathList>. Note that the first math listed in the definition in the example above counts as one item, even when lists are merged, because it is specified as a tuple (enclosed by parentheses). The second math in the definition counts as 1 item when lists are not merged, and 3 items if they are merged.


Property Example: latex

The latex property returns the LaTeX code required to render the maths in an array. The LaTeX code for individual items can be accessed using array notation and then appending the latex property.


Property Example: text

The text property returns the maths in text format in an array. The text for individual items can be accessed using array notation and then appending the text property.

Last updated on