Shuffle Parameter - Shuffling Data, a Deck or a List |
Top Previous Next |
Note that we will look at data parameters later in this document.
You can create a shuffle parameter from an existing Data parameter, Deck parameter or List parameter.
$p=data(5,6,7,9,12) $s=shuffle($p)
$s will contain a shuffled version of $p
You can also create shuffled versions of data parameters which contain text.
$p=data("x2-4","2x2-3","-x2+7","-2x2-3) $s=shuffle($p)
$s will contain the three functions in a shuffled state.
Shuffling data parameters could, for example, be used to create a randomly shuffled set of answers to a question. This might be useful for randomised multi-choice questions.
Using Shuffle Parameters with DecksDeck parameters contain a fixed list of all 52 cards in a standard deck of cards. Often, you will want to shuffle the deck to create a random list.
$d=deck() $s=shuffle($d)
$s will contain a shuffled deck of cards.
Using Shuffle Parameters with Lists
Note that this section uses the $s[] reference notation that is discussed later in this document.
Data parameters and list parameters are almost identical. The only difference is that a data parameter will report all values at once where a list parameter will only report the current (randomly selected) value.
If you wish to shuffle a list parameter, you need to force the parameter to report all values at once.
$p=list(5,6,7,9,12) $s=shuffle($p)
In this example, $s will only contain ONE value from $p
$p=list(5,6,7,9,12) $s=shuffle($p[])
In this example, $s will only contain a shuffled list of ALL values from $p |