Changeset 13482 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters
- Timestamp:
- 12/17/15 20:43:07 (9 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
r12891 r13482 56 56 57 57 private void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 58 // TODO: adapt to interpreter semantics. The HL interpreter also allows Boolean operations on reals 58 59 if (node.Subtrees.Any()) { 59 60 if (node.Symbol is Addition) { … … 83 84 } else if (node.Symbol is Or) { 84 85 FormatOperator(node, "||", strBuilder); 86 } else if (node.Symbol is Xor) { 87 FormatOperator(node, "^", strBuilder); 85 88 } else if (node.Symbol is Sine) { 86 89 FormatFunction(node, "Math.Sin", strBuilder); 87 90 } else if (node.Symbol is Subtraction) { 88 Format Operator(node, "-", strBuilder);91 FormatSubtraction(node, strBuilder); 89 92 } else if (node.Symbol is Tangent) { 90 93 FormatFunction(node, "Math.Tan", strBuilder); … … 142 145 } 143 146 147 private void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 148 if (node.SubtreeCount == 1) { 149 strBuilder.Append("-"); 150 FormatRecursively(node.GetSubtree(0), strBuilder); 151 return; 152 } 153 //Default case: more than 1 child 154 FormatOperator(node, "-", strBuilder); 155 } 156 144 157 private void FormatOperator(ISymbolicExpressionTreeNode node, string symbol, StringBuilder strBuilder) { 145 158 strBuilder.Append("("); … … 176 189 } 177 190 178 var orderedNames = varNames.OrderBy(n => n, new NaturalStringComparer()).Select(n => "double " + n);191 var orderedNames = varNames.OrderBy(n => n, new NaturalStringComparer()).Select(n => "double " + n); 179 192 strBuilder.Append(string.Join(", ", orderedNames)); 180 193
Note: See TracChangeset
for help on using the changeset viewer.