Changeset 14520
- Timestamp:
- 12/22/16 11:18:55 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.ExpressionGenerator/HeuristicLab.ExpressionGenerator/3.4/Expression.cs
r14515 r14520 118 118 break; 119 119 var args = Arguments.ToList(); 120 sb.Append("(");121 120 // the Label should be known to the infix parser 122 121 if (Label == "+" || Label == "-" || Label == "*" || Label == "/") { 123 if (Label == "/")124 sb.Append("1 / ");125 122 if (args.Count == 1) { 126 sb.Append(string.Format( "{0}", args[0].PrintInfix()));123 sb.Append(string.Format(Label == "/" ? "1 / {0}" : "{0}", args[0].PrintInfix())); 127 124 } else { 128 sb.Append("("); 129 var last = args.Last(); 130 for (int i = 0; i < args.Count - 1; ++i) { 131 var arg = args[i]; 132 sb.Append(string.Format("{0} {1} ", arg.PrintInfix(), Label)); 125 if (Label == "/") { 126 sb.Append(string.Format("{0} / ", args[0].PrintInfix())); 127 var remaining = args.Count - 1; 128 if (remaining == 1) 129 sb.Append(args[1].PrintInfix()); 130 else { 131 sb.Append("("); 132 var last = args.Last(); 133 for (int i = 1; i < args.Count - 1; ++i) { 134 var arg = args[i]; 135 sb.Append(string.Format("{0} {1} ", arg.PrintInfix(), "*")); 136 } 137 sb.Append(string.Format("{0})", last.PrintInfix())); 138 } 139 } else { 140 sb.Append("("); 141 var last = args.Last(); 142 for (int i = 0; i < args.Count - 1; ++i) { 143 var arg = args[i]; 144 sb.Append(string.Format("{0} {1} ", arg.PrintInfix(), Label)); 145 } 146 sb.Append(string.Format("{0})", last.PrintInfix())); 133 147 } 134 sb.Append(string.Format("{0})", last.PrintInfix()));135 148 } 136 149 } else { … … 139 152 for (int i = 0; i < args.Count - 1; ++i) { 140 153 var arg = args[i]; 141 sb.Append(string.Format("{0}, ", arg.PrintInfix() , Label));154 sb.Append(string.Format("{0}, ", arg.PrintInfix())); 142 155 } 143 156 sb.Append(string.Format("{0})", last.PrintInfix())); 144 157 } 145 sb.Append(")");146 158 break; 147 159 }
Note: See TracChangeset
for help on using the changeset viewer.