ReferenceselectPrimeNumbers

<selectPrimeNumbers/>

Randomly selects prime numbers from a range to create document variants

<selectPrimeNumbers/> is a Math component that selects prime numbers at random from a specified range. Selections generate variants of the document.

Attributes and Properties

Attributes for <selectPrimeNumbers>

Other (8)
asList

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

numberList. Primes to exclude from the selection.

_listOfNumberLists. Combinations of values that should not be selected together.

integer. Default value: 2. Lower bound (inclusive) of the prime range to select from.

numToSelect

integer. Default value: 1. How many prime numbers to select.

keyword. Sort order applied to the selected primes.

ValueDescription
unsorted (default)Preserve the random selection order.
increasingSort the selected primes in increasing order.
decreasingSort the selected primes in decreasing order.

integer. Default value: 100. Upper bound (inclusive) of the prime range to select from.

boolean. Default value: false. Whether the same prime can be selected more than once.

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 <selectPrimeNumbers name="s">

Other (6)
$s.exclude

numberList. Primes to exclude from the selection.

$s.from

integer. Lower bound (inclusive) of the prime range to select from.

$s.numToSelect

integer. How many prime numbers to select.

$s.sort

text. Sort order applied to the selected primes.

$s.to

integer. Upper bound (inclusive) of the prime range to select from.

$s.withReplacement

boolean. Whether the same prime can be selected more than once.

Common to all components (4)
$s.doenetML

text. The DoenetML source code that produced this component.

$s.hide

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

$s.isResponse

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

$s.styleNumber

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

Examples

Example: Default <selectPrimeNumbers/>

The default <selectPrimeNumbers/> has a sequence range from 22 to 9797.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Example: Generate multiple selections

Three numbers that are selected between 22 and 5050. Individual selections can be accessed using array notation.


Example: Assigning descriptive names to multiple selections

The numToSelect attribute allows for selection of multiple values within the range of a single <selectPrimeNumbers/> component. Multiple selections are made without replacement. Selections can be assigned more descriptive names by defining individual components which reference the selected values.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.

Attribute Examples

Attribute Example: sort

The sort attribute determines how selected results are sorted. It accepts three values:

  • "unsorted" (default) - results are in the order they were selected
  • "increasing" - results are sorted in increasing order
  • "decreasing" - results are sorted in decreasing order

Alternatively, sort and sort="true" are equivalent to sort="increasing", and sort="false" is equivalent to sort="unsorted".

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: from, to

The from and to attributes specify the endpoints of the selection interval. These endpoints are not required to be prime numbers.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: exclude

The exclude attribute specifies values to exclude in the selection. Doenet will throw an error if sufficient primes are not available in the selection interval without replacement. If repetitions are allowed, the withReplacement attribute can be used.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: withReplacement

If selection with replacement is the desired behavior, use the withReplacement attribute.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.


Attribute Example: excludeCombinations

The excludeCombinations attribute can be used to exclude undesired combinations of prime numbers.

Select a new page variant from the pulldown menu at the top of the editor to see different variants of the document.