[poincare] Align implementation of shallowReduce in Symbol and Function

This commit is contained in:
Ruben Dashyan
2019-11-19 10:59:54 +01:00
committed by Léa Saviot
parent 70c9d063a2
commit 95c7235831
2 changed files with 10 additions and 11 deletions

View File

@@ -112,16 +112,16 @@ Expression Function::replaceSymbolWithExpression(const SymbolAbstract & symbol,
}
Expression Function::shallowReduce(ExpressionNode::ReductionContext reductionContext) {
Function f(*this);
Expression e = SymbolAbstract::Expand(f, reductionContext.context(), true);
if (!e.isUninitialized()) {
replaceWithInPlace(e);
return e.deepReduce(reductionContext);
Expression result = SymbolAbstract::Expand(*this, reductionContext.context(), true);
if (result.isUninitialized()) {
if (reductionContext.symbolicComputation()) {
return *this;
}
result = Undefined::Builder();
}
if (!reductionContext.symbolicComputation()) {
return replaceWithUndefinedInPlace();
}
return *this;
replaceWithInPlace(result);
// The stored expression is as entered by the user, so we need to call reduce
return result.deepReduce(reductionContext);
}
Expression Function::deepReplaceReplaceableSymbols(Context * context, bool * didReplace) {

View File

@@ -175,8 +175,7 @@ Expression Symbol::shallowReduce(ExpressionNode::ReductionContext reductionConte
}
}
Symbol s = *this;
Expression result = SymbolAbstract::Expand(s, reductionContext.context(), true);
Expression result = SymbolAbstract::Expand(*this, reductionContext.context(), true);
if (result.isUninitialized()) {
if (reductionContext.symbolicComputation()) {
return *this;