From: dpvc v. a. <we...@ma...> - 2009-07-31 02:40:22
|
Log Message: ----------- handle negative fraction reductions Modified Files: -------------- pg/macros: contextFraction.pl Revision Data ------------- Index: contextFraction.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/contextFraction.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -Lmacros/contextFraction.pl -Lmacros/contextFraction.pl -u -r1.5 -r1.6 --- macros/contextFraction.pl +++ macros/contextFraction.pl @@ -499,6 +499,23 @@ return $self->SUPER::class; } +# +# Handle reductions of negative fractions +# +sub reduce { + my $self = shift; + my $reduce = $self->context->{reduction}; + if ($self->{value}->class eq 'Fraction') { + $self->{value} = $self->{value}->reduce; + if ($reduce->{'-n'} && $self->{value}{data}[0] < 0) { + $self->{value}{data}[0] = -$self->{value}{data}[0]; + return Parser::UOP::Neg($self); + } + return $self; + } + return $self->SUPER::reduce; +} + ########################################################################### package context::Fraction::Real; |