public static Node SubstituteNest(Node receiver, Node provider, List <Operator> operators) { VariableNode leftVariable = (VariableNode)provider.Children[0]; Transform transform = new Transform(); VariableNode leftTransform = new VariableNode(); leftTransform.VariableNodeType = VariableNodeType.RequireVariable; leftTransform.Variable = "V" + leftVariable.Variable; transform.Left = leftTransform; transform.Right = provider.Children[1]; bool didTransform = false; Node outNode = TransformBranchFunctions.TransformBranchesWithTransformToOneResult(receiver, transform, operators, ref didTransform); if (didTransform) { return(outNode); } return(null); }
public static void ProcessUntransformedAnswer(PotentialAnswer potentialAnswer, ConcurrentBag <string> existingEquationStrings, ref bool foundNonExistantAnswer, ConcurrentBag <PotentialAnswer> potentialAnswers, List <Operator> operators, List <Goal> goals, List <Transform> inTransforms, ref bool stopSolving, bool useSubstitutions) { List <Node> newAnswers = TransformBranchFunctions.TransformBranchesWithTransforms(potentialAnswer.Equation, inTransforms, operators); potentialAnswer.Transformed = true; foreach (Node newAnswer1 in newAnswers) { Node newAnswer2 = EvaluateBranches.Evaluate(newAnswer1); ProcessNewAnswer(newAnswer1, existingEquationStrings, ref foundNonExistantAnswer, potentialAnswers, operators, goals); ProcessNewAnswer(newAnswer2, existingEquationStrings, ref foundNonExistantAnswer, potentialAnswers, operators, goals); if (stopSolving) { break; } } if (useSubstitutions) { Substitute(potentialAnswer.Equation, potentialAnswers, existingEquationStrings, ref foundNonExistantAnswer, operators, goals, ref stopSolving); } }