[system] / trunk / pg / macros / contextTF.pl Repository:
ViewVC logotype

View of /trunk/pg/macros/contextTF.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5392 - (download) (as text) (annotate)
Sun Aug 19 21:50:23 2007 UTC (12 years, 6 months ago) by dpvc
File size: 908 byte(s)
Move the context creation to the _init routine so that modifications
to main:: occur at initialization time, not when the file is loaded.

    1 loadMacros("MathObjects.pl","contextString.pl");
    2 
    3 =head3 Context("TF")
    4 
    5  ##########################################################
    6  #
    7  #  Implements contexts for string-valued answers especially
    8  #  for matching problems (where you match against T and F).
    9  #
   10  #  Context("TF");
   11  #
   12  #  You can add new strings to the context as needed (or remove old ones)
   13  #  via the Context()->strings->add() and Context()-strings->remove()
   14  #  methods.
   15  #
   16  #  Use:
   17  #
   18  #  ANS(string_cmp("T","F"));
   19  #
   20  #  when there are two answers, the first being "T" and the second being "F".
   21  #
   22 
   23 =cut
   24 
   25 sub _contextTF_init {
   26 
   27   my $context = $main::context{TF} = Parser::Context->getCopy("String");
   28   $context->strings->are(
   29     "T" => {value => 1},
   30     "F" => {value => 0},
   31     "True" => {alias => "T"},
   32     "False" => {alias => "F"},
   33   );
   34 
   35   main::Context("TF");  ### FIXME:  probably should require author to set this explicitly
   36 }
   37 
   38 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9