|non random values||topic started 3/2/2001; 11:32:15 AM
last post 3/2/2001; 11:44:38 AM
|Arnold K. Pizer - Re: non random vaules
3/2/2001; 11:44:38 AM (reads: 1065, responses: 0)
|This is easy to do. For an example look at e.g. setAlgebra2Powers/srw1_2_26.pg|
Suppose you want to work with the pairs (a,b) = (7,15), (11,2), (2,1), and (-3,3). Set up the two arrays
@a_val = (7,11,2,-3);
Since arrays in Perl are indexed starting with zero (so we have indices 0,1,2,3 in the above example), we pick an index tag by
$tag = random(0,3,1);
Then $a_val[$tag] and $b_val[$tag] will be one of the random pairs above.
Tom Shemanske's WeBWorK Newbie Guide (under write/modify problems) describes the syntax for arrays in Perl.