Forum archive 2000-2006

Michael Gage - qa

Michael Gage - qa

by Arnold Pizer -
Number of replies: 0
inactiveTopicqa topic started 8/28/2001; 12:10:13 AM
last post 8/28/2001; 12:10:13 AM
userMichael Gage - qa  blueArrow
8/28/2001; 12:10:13 AM (reads: 2018, responses: 0)


qa stands for "question and answer". This subroutine splits an array of alternating questions and answers into two arrays. It is frequently easier to enter the questions and answers in pairs rather than to enter them separately in different arrays. The latter procedure makes it easier to mismatch the question and its answer when modifying a problem. This simple qa subroutine is seldom needed, but is kept for backword compatibility.


qa(~~@questions, ~~@answers, $question1, $answer1, $question2, $answer2...)


~~@questions and ~~@answers are references to arrays which will contain the questions and answers respectively. The remaining inputs in the list are questions and answers alternating.


Places the questions in the @question array and the answers in the @answer array




@questions=(); #initialize the question and answer arrays.
qa(~~@questions, ~~@answers,
"What color is the sky?"
"What is the square root of 4"


* Make sure that the arrays @questions and @answers have been initialized.
* In PG problems ~~@questions indicates a reference to an array.
In macro packages (and pure perl) use \\@questions instead.
* Perl allows the use of => to separate questions and answers:
"This is a question1" => "and aswer 1", "question 2" => " and answer 2"
which might be clearer. (In this context => is just an alias for the comma.)

* This subroutine is defined in

See Also
This simple qa subroutine is seldom needed, but provides backword compatibility with earlier problems. See,, and whose objects all have a qa method for entering questions and answers. The use of these objects can simplify the creation of matching questions or multiple choice questions.


<| Post or View Comments |>