## Set up a matched list by creating a new matched list object.
## $matched_list_ptr points to a new matched list object.
$matched_list_ptr = new_match_list();
## Now assign to the matched list object an array of "question", "answer"
## pairs from which a subset will be selected.
##
$matched_list_ptr -> qa ("R stands for", "Red",
"O stands for", "Orange",
"Y stands for", "Yellow",
"G stands for", "Green",
"B stands for", "Blue",
"I stands for", "Indigo",
"V stands for", "Violet"
);
## Choose four of the possible question-answer pairs
$matched_list_ptr -> choose(4);
## Ok, we are ready to begin...
##
TEXT(beginproblem());
## In the text block below, we will print the
## selection questions with (uncommented of course)
## \{ $matched_list_ptr -> print_q \}
## and corresponding (and permuted) answers with
## Print the corresponding answers
## \{ $matched_list_ptr -> print_a \}
BEGIN_TEXT
$PAR
This problem below is a matching problem
using four of seven possible questions and corresponding answers.
$BR
$BBOLD Matching Problem 1: $EBOLD In the colors of the visible light
spectrum, the acronym ROYGBIV is often used. $BR
Here is the list of questions:
\{ $matched_list_ptr -> print_q \}
$PAR
Here is the (permuted list) of answers
\{ $matched_list_ptr -> print_a \}
END_TEXT
## Provide the answer string
ANS( str_cmp( $matched_list_ptr->ra_correct_ans ) ) ;
## Now a simple matching example using questions in math mode
## Note the invocation of math mode is inside the (double) quotes
## which define the question-answer pairs
##
$new_matched_list_ptr = new_match_list();
$new_matched_list_ptr -> qa ("\( \tan^{-1}x \)",
"\( \displaystyle{\frac{1}{1+x^2}} \)",
"\( \ln(1 + x^2) \)",
"\( \displaystyle{\frac{2x}{1+x^2}} \)",
"\( \ln(\sqrt{1+x^2}) \)",
"\( \displaystyle{\frac{x}{1+x^2}} \)"
);
## Choose all three of the possible question-answer pairs
$new_matched_list_ptr -> choose(3);
BEGIN_TEXT
$PAR
This problem below is a matching problem
using all three possible questions and corresponding answers.
$BR
$BBOLD Matching Problem 2: $EBOLD Match the functions to their derivatives
$BR
Here is the list of questions:
\{ $new_matched_list_ptr -> print_q \}
$PAR
Here is the (permuted list) of answers
\{ $new_matched_list_ptr -> print_a \}
END_TEXT
## Provide the answer string
ANS( str_cmp( $new_matched_list_ptr->ra_correct_ans ) ) ;