List (MathObject Class)

From WeBWorK_wiki
Revision as of 16:57, 2 August 2012 by Dpvc (talk | contribs) (Created page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The List Class

The List class implements arbitrary lists of other MathObjects. There is no restriction on what can be placed in a list, including other lists, other than what can be specified in the Context. For example, 1,<2,3>,5-2i,DNE is a valid List. The answer checker for lists allows you to specify if the order of the list matters or not, and students can enter their answers in any order by default. Lists are useful when you don't want to give away the number of answers a student may have to come up with, for example, or when you don't want to have to worry about the order of the answers.

   $L = List(1,3+i,"DNE",Vector(3,2,1));
   $L = List("1,3+i,DNE,<3,2,1>");       # provided i and Vectors are in the context
   $L = Compute("1,3+i,DNE,<3,2,1>");    # same caveat

Lists can also be enclosed in delimiters, e.g., (1,DNE), and you can have lists of lists, as in (1,increases),(3.5,decreases). If you include delimiters in a list, then students must as well, and if you leave them off, students must as well. If you create a list via the List() constructor as in the first example above, then this assumes no delimiters are needed. There are flags for the answer checker that you can use to change how students must enter delimiters.