Parent Directory
|
Revision Log
Revision 5736 - (view) (download)
| 1 : | sh002i | 5540 | ########################################################### |
| 2 : | # | ||
| 3 : | # Example showing how to use the Parser's function | ||
| 4 : | # answer checker. | ||
| 5 : | # | ||
| 6 : | |||
| 7 : | DOCUMENT(); # This should be the first executable line in the problem. | ||
| 8 : | |||
| 9 : | loadMacros( | ||
| 10 : | "PGbasicmacros.pl", | ||
| 11 : | "PGanswermacros.pl", | ||
| 12 : | "Parser.pl", | ||
| 13 : | "parserUtils.pl", | ||
| 14 : | ); | ||
| 15 : | |||
| 16 : | TEXT(beginproblem()); | ||
| 17 : | |||
| 18 : | ########################################################### | ||
| 19 : | # | ||
| 20 : | # The setup | ||
| 21 : | # | ||
| 22 : | Context('Interval')->variables->add(a=>'Real'); | ||
| 23 : | $x = Formula('x'); $a = Formula('a'); | ||
| 24 : | |||
| 25 : | $f = log($x-$a); | ||
| 26 : | $I = Formula("(-infinity,a]"); | ||
| 27 : | |||
| 28 : | ########################################################### | ||
| 29 : | # | ||
| 30 : | # The problem text | ||
| 31 : | # | ||
| 32 : | |||
| 33 : | Context()->texStrings; | ||
| 34 : | BEGIN_TEXT | ||
| 35 : | |||
| 36 : | Suppose \(f(x) = $f\). | ||
| 37 : | $PAR | ||
| 38 : | Then \(f\) is undefined for \(x\) in the interval(s) | ||
| 39 : | \{ans_rule(20)\}. | ||
| 40 : | $PAR | ||
| 41 : | ${BCENTER} | ||
| 42 : | ${BSMALL} | ||
| 43 : | To enter more than one interval, separate them by commas.$BR | ||
| 44 : | Use ${LQ}${BTT}infinity${ETT}${RQ} for ${LQ}\(\infty\)${RQ} and | ||
| 45 : | ${LQ}${BTT}-infinity${ETT}${RQ} for ${LQ}\(-\infty\)${RQ}.$BR | ||
| 46 : | Enter ${LQ}${BTT}NONE${ETT}${RQ} if the function is always defined. | ||
| 47 : | ${ESMALL} | ||
| 48 : | ${ECENTER} | ||
| 49 : | |||
| 50 : | END_TEXT | ||
| 51 : | Context()->normalStrings; | ||
| 52 : | |||
| 53 : | ########################################################### | ||
| 54 : | # | ||
| 55 : | # The answers | ||
| 56 : | # | ||
| 57 : | ANS(List($I)->cmp( | ||
| 58 : | list_type => 'a list of intervals', # override these names to avoid | ||
| 59 : | entry_type => "an interval", # 'formula returning ...' messages | ||
| 60 : | )); | ||
| 61 : | Context()->variables->remove('x'); # error if 'x' is used in answer | ||
| 62 : | |||
| 63 : | $showPartialCorrectAnswers = 1; | ||
| 64 : | |||
| 65 : | ########################################################### | ||
| 66 : | |||
| 67 : | ENDDOCUMENT(); # This should be the last executable line in the problem. |
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |