Update of /cvsroot/aimmath/AIM/WEB-INF/maple/aim
In directory sc8-pr-cvs1:/tmp/cvs-serv13337
Added Files:
AnswerHints.mpl
Log Message:
Starting a new package: AnswerHints. Similar to SyntaxHints, but for catching mathematical errors, not syntax errors.
--- NEW FILE: AnswerHints.mpl ---
# Copyright (C) 2003 Ken Monks
# Distributed without warranty under the GPL - see README for details
read("Package.mpl"):
Package("aim/AnswerHints",
"This package contains functions that check for common mathematical errors
(as opposed to syntax errors) in a student's answer and provide some
guidance to them about possible causes for errors in their answers.
"):
######################################################################
`Package/Assign`(
`Hints/CheckSigns`::boolean,
"This routine returns @true@ if it can determine if @ans@ differs
from the @rightans@ only by having the wrong signs in zero or more
subexpressions. Note that this routine will also return @true@ if @ans@
is equal to @rightans@.
",
proc(ans,rightans)
local And,elt,relt,absans,absrightans,Member;
if type(rightans,InertExpr) then
return `Hints/CheckSigns`(ans,Value(rightans))
elif type(rightans,SET) then
return `Hints/CheckSigns`(ans,rightans['toSet'])
fi:
And:=proc() evalb({args}={true}); end:
Member:=proc(e,S)
local i:
for i in S do
if `Hints/CheckSigns`(e,i) then return i fi:
od:
return NULL:
end:
try
if type({ans,rightans},{set(list)}) then
return nops(ans)=nops(rightans) and
And(op(zip(`Hints/CheckSigns`,ans,rightans)))
elif type({ans,rightans},{set(set)}) then
if nops(ans)<>nops(rightans) then return false fi:
absans:=map(abs,ans); absrightans:=map(abs,rightans);
for elt in absans do
relt:=Member(elt,absrightans);
if relt=NULL then
return false
else
absrightans:=absrightans minus {relt};
fi:
od:
return true;
elif type({ans,rightans},set(function)) or
type({ans,rightans},set(`^`)) then
return op(0,ans)=op(0,rightans) and
nops(ans)=nops(rightans) and
`Hints/CheckSigns`([op(ans)],[op(rightans)]);
elif type({ans,rightans},set(`+`)) or
type({ans,rightans},set(`*`)) then
return `Hints/CheckSigns`({op(ans)},{op(rightans)})
elif type({ans,rightans},set(algebraic)) then
return `aim/Test`(abs(ans),abs(rightans))
fi:
catch : end:
return false;
end
):
EndPackage():
|