ReferencemathList

<mathList>

A list of math expressions

<mathList> is a Math component that defines a collection, or list, of <math> components. 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>

Other (13)
asList

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

avoidScientificNotation

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

displayDecimals

Number of decimal places to display when rendering this number.

displayDigits

Number of significant digits to display when rendering this number.

displaySmallAsZero

Threshold below which numbers are displayed as zero.

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.

padZeros

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

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

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 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">

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 math list.

$m.numValues

number. The number of math expressions 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 (3)
$m.doenetML

text. The DoenetML source code that produced this component.

$m.hide

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

$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 “maths”, or <math> components. 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 components stored in a <mathList>. Note that the first math listed in the definition in the example above counts as one component, even when lists are merged, because it is specified as a tuple (enclosed by parentheses). The second math in the definition counts as 1 component when lists are not merged, and 3 components 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 components 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 components can be accessed using array notation and then appending the text property.