Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim
In directory sc8-pr-cvs1:/tmp/cvs-serv4786
Modified Files:
Compile.mpl Inert.mpl LaTeX.mpl SET.mpl SyntaxHints.mpl
Test.mpl
Log Message:
several bug fixes and tweaks to improve handling of SET's and Inerts representing SETs
Index: Compile.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Compile.mpl,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Compile.mpl 30 Aug 2003 21:04:04 -0000 1.6
--- Compile.mpl 19 Sep 2003 04:11:15 -0000 1.7
***************
*** 400,404 ****
nam,flagnum,lines]);
fi;
! setans := sprintf("questionversion['RightAnswer'] := %s;\n",text);
printvar := "postamble_";
##########
--- 400,407 ----
nam,flagnum,lines]);
fi;
! # KM Change this so it evals the teacher's answer in case a table is submitted
! # WAS: setans := sprintf("questionversion['RightAnswer'] := %s;\n",text);
! setans := sprintf("questionversion['RightAnswer'] := eval(%s);\n",text);
! # END KM
printvar := "postamble_";
##########
***************
*** 611,615 ****
RETURN([cat(__("Problem while parsing answer test:"),
sprintf("\n<br/>\n%s\n<br/><br/>\n%s\n<br/><br/>\n",
! err[1],err[3])),
nam,atestflagnum,lines]);
fi;
--- 614,618 ----
RETURN([cat(__("Problem while parsing answer test:"),
sprintf("\n<br/>\n%s\n<br/><br/>\n%s\n<br/><br/>\n",
! err[1],err[3])),
nam,atestflagnum,lines]);
fi;
***************
*** 881,886 ****
##########
elif member(flag, {"value>","penalty>","answer>","answertest>",
! "answervariable>","prompt>","postprompt>",
! "mapletype>","forbid>"}) then
RETURN([sprintf(__("%s flag is not allowed for multipart questions."),flag)
,nam,flagnum,lines]);
--- 884,889 ----
##########
elif member(flag, {"value>","penalty>","answer>","answertest>",
! "answervariable>","prompt>","postprompt>",
! "mapletype>","forbid>"}) then
RETURN([sprintf(__("%s flag is not allowed for multipart questions."),flag)
,nam,flagnum,lines]);
***************
*** 1581,1590 ****
proc(f)
local f_inert,params,locals,optseq,remtab,
! stats,desc,globals,lexseq,param;
f_inert := ToInert(eval(f));
if not(type(f_inert,function) and
! op(0,f_inert) = _Inert_PROC) then
error("Argument is not a procedure");
fi;
--- 1584,1593 ----
proc(f)
local f_inert,params,locals,optseq,remtab,
! stats,desc,globals,lexseq,param;
f_inert := ToInert(eval(f));
if not(type(f_inert,function) and
! op(0,f_inert) = _Inert_PROC) then
error("Argument is not a procedure");
fi;
***************
*** 1626,1630 ****
_Inert_EXPSEQ(
_Inert_UNEVAL(
! _Inert_NAME("Answer"))))),
op(stats),
_Inert_ASSIGN(
--- 1629,1633 ----
_Inert_EXPSEQ(
_Inert_UNEVAL(
! _Inert_NAME("Answer"))))),
op(stats),
_Inert_ASSIGN(
***************
*** 1692,1700 ****
return(
_Inert_ASSIGN(
! _Inert_TABLEREF(
! _Inert_PARAM(1),
! _Inert_EXPSEQ(
! _Inert_UNEVAL(_Inert_NAME("RawMark")))),
! op(op(2,x))),
_Inert_RETURN(_Inert_NAME("NULL")));
fi;
--- 1695,1703 ----
return(
_Inert_ASSIGN(
! _Inert_TABLEREF(
! _Inert_PARAM(1),
! _Inert_EXPSEQ(
! _Inert_UNEVAL(_Inert_NAME("RawMark")))),
! op(op(2,x))),
_Inert_RETURN(_Inert_NAME("NULL")));
fi;
***************
*** 1744,1754 ****
proc(vars::list(string),f)
local f_inert,params,locals,optseq,remtab,stats,desc,
! globals,lexseq,globalnames,newglobals,newlocals,
! transtable,i,j,loc,nam;
f_inert := ToInert(eval(f));
if not(type(f_inert,function) and
! op(0,f_inert) = _Inert_PROC) then
error("Second argument is not a procedure");
fi;
--- 1747,1757 ----
proc(vars::list(string),f)
local f_inert,params,locals,optseq,remtab,stats,desc,
! globals,lexseq,globalnames,newglobals,newlocals,
! transtable,i,j,loc,nam;
f_inert := ToInert(eval(f));
if not(type(f_inert,function) and
! op(0,f_inert) = _Inert_PROC) then
error("Second argument is not a procedure");
fi;
Index: Inert.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Inert.mpl,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Inert.mpl 12 Sep 2003 03:16:07 -0000 1.5
--- Inert.mpl 19 Sep 2003 04:11:15 -0000 1.6
***************
*** 269,278 ****
G['NeedsParentheses'] and
F['Precedence']>G['Precedence'] then
! ParenArgs:=ParenArgs,cat("\\left(",i['TeX'],"\\right)")
else
! ParenArgs:=ParenArgs,i['TeX'];
fi:
else
! ParenArgs:=ParenArgs,i;
fi:
od:
--- 269,278 ----
G['NeedsParentheses'] and
F['Precedence']>G['Precedence'] then
! ParenArgs:=eval(ParenArgs),cat("\\left(",i['TeX'],"\\right)")
else
! ParenArgs:=eval(ParenArgs),i['TeX'];
fi:
else
! ParenArgs:=eval(ParenArgs),eval(i);
fi:
od:
***************
*** 1047,1054 ****
"The Inert Set function (represents a SET object).",
`new/Inert`(`new/SET`, # Map
! proc() # TeX
! cat("\\left\\{",TeX(args),"\\right\\}");
! end,
! -1, # Nargs
'anything', # Domain
"SET", # Name
--- 1047,1056 ----
"The Inert Set function (represents a SET object).",
`new/Inert`(`new/SET`, # Map
! proc() # TeX
! cat("\\left\\{",
! TeX(args),
! "\\right\\}")
! end,
! -1, # Nargs
'anything', # Domain
"SET", # Name
***************
*** 1067,1072 ****
"The Inert Set function (represents a SET object).",
`new/Inert`(`SET/Union`, # Map
! proc() # TeX
! cat(TeX(args[1]),seq(cat("\\cup{}",TeX(args[i])),i=2..nargs))
end,
-1, # Nargs
--- 1069,1076 ----
"The Inert Set function (represents a SET object).",
`new/Inert`(`SET/Union`, # Map
! proc() # TeX
! if nargs=0 then "\\{\\}" else
! cat(TeX(args[1]),seq(cat("\\cup{}",TeX(args[i])),i=2..nargs))
! fi:
end,
-1, # Nargs
Index: LaTeX.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/LaTeX.mpl,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** LaTeX.mpl 15 Sep 2003 16:17:56 -0000 1.11
--- LaTeX.mpl 19 Sep 2003 04:11:15 -0000 1.12
***************
*** 509,515 ****
else
# KM
! # Make the LaTeX command aware of InertExpr objects and how to format them
if type(eval(e),InertExpr) then
texlist := [e['TeX']];
else
# end KM
--- 509,520 ----
else
# KM
! # Make the LaTeX command aware of InertExpr and SET objects
! # and how to format them
if type(eval(e),InertExpr) then
texlist := [e['TeX']];
+ elif type(eval(e),'SET') then
+ texlist := ["\\left\\{",
+ `Util/CommaJoin`(op(map(`aim/LaTeX`,[op(e['Elements'])]))),
+ "\\right\\}"];
else
# end KM
Index: SET.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/SET.mpl,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SET.mpl 12 Sep 2003 03:16:07 -0000 1.2
--- SET.mpl 19 Sep 2003 04:11:15 -0000 1.3
***************
*** 87,92 ****
`SET/isEqual`::boolean,
"Returns true if the set represented by SET @A@ equals the set represented by SET @B@ (order of elements doesn't matter).",
! proc(A::SET,B::SET)
! evalb(A['toSet']=B['toSet']);
end
):
--- 87,95 ----
`SET/isEqual`::boolean,
"Returns true if the set represented by SET @A@ equals the set represented by SET @B@ (order of elements doesn't matter).",
! proc(A::{SET,set},B::{SET,set})
! local a,b;
! a:=`if`(type(A,SET),A['toSet'],A);
! b:=`if`(type(B,SET),B['toSet'],B);
! evalb(a=b);
end
):
***************
*** 132,138 ****
goodguy:=true;
for k from 2 to nargs do
! if not `SET/isMember`(j,B) then goodguy:=false; break; fi
od:
! if goodguy then L:=L,j fi;
od:
eval(`new/SET`(L));
--- 135,141 ----
goodguy:=true;
for k from 2 to nargs do
! if not `SET/isMember`(x,B) then goodguy:=false; break; fi
od:
! if goodguy then L:=L,x fi;
od:
eval(`new/SET`(L));
Index: SyntaxHints.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/SyntaxHints.mpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SyntaxHints.mpl 1 Sep 2003 05:55:59 -0000 1.4
--- SyntaxHints.mpl 19 Sep 2003 04:11:15 -0000 1.5
***************
*** 1011,1015 ****
"Return a string that a student could type to enter @e@",
proc(e::anything)
! local s;
if nargs = 0 then
"";
--- 1011,1015 ----
"Return a string that a student could type to enter @e@",
proc(e::anything)
! local s,x;
if nargs = 0 then
"";
***************
*** 1023,1026 ****
--- 1023,1030 ----
e;
# KM
+ elif type(e,SET) then
+ cat("{",
+ `Util/CommaJoin`(op(map(`aim/EntryHint`,e['Elements']))),
+ "}");
elif type(e,InertExpr) then
`aim/EntryHint`(Value(e));
Index: Test.mpl
===================================================================
RCS file: /cvsroot/aimmath/AIM/WEB-INF/maple/aim/Test.mpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Test.mpl 1 Sep 2003 05:55:59 -0000 1.4
--- Test.mpl 19 Sep 2003 04:11:15 -0000 1.5
***************
*** 100,107 ****
`Package/Assign`(
`aim/TestSET`::boolean,
! "Return @true@ if both arguments are @SET@ objects and #`SET/isEqual`# determines they represent the same set. Returns false otherwise.
",
proc(ans::anything,rightans::anything)
! if type(ans,SET) and type(rightans,SET) then
return `SET/isEqual`(ans,rightans);
else
--- 100,108 ----
`Package/Assign`(
`aim/TestSET`::boolean,
! "Return @true@ if @rightans@ is a @SET@, @ans@ is a @SET@ or a @set@
! and they represent the same set. Returns false otherwise.
",
proc(ans::anything,rightans::anything)
! if type(ans,{SET,set}) and type(rightans,SET) then
return `SET/isEqual`(ans,rightans);
else
|