Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16359 for trunk


Ignore:
Timestamp:
12/10/18 16:34:32 (6 years ago)
Author:
gkronber
Message:

#2915: allow two different syntactical forms for power ( (a)(b) and pow(a,b) ) in the infix formatter and merged two identical branches (for all operators)

Location:
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs

    r15583 r16359  
    6262      if (node.SubtreeCount > 1) {
    6363        var token = GetToken(node.Symbol);
    64         if (token == "+" || token == "-" || token == "OR" || token == "XOR") {
    65           strBuilder.Append("(");
    66           FormatRecursively(node.Subtrees.First(), strBuilder);
    67 
    68           foreach (var subtree in node.Subtrees.Skip(1)) {
    69             strBuilder.Append(" ").Append(token).Append(" ");
    70             FormatRecursively(subtree, strBuilder);
    71           }
    72           strBuilder.Append(")");
    73 
    74         } else if (token == "*" || token == "/" || token == "AND") {
     64        // operators
     65        if (token == "+" || token == "-" || token == "OR" || token == "XOR" ||
     66            token == "*" || token == "/" || token == "AND" ||
     67            token == "^") {
    7568          strBuilder.Append("(");
    7669          FormatRecursively(node.Subtrees.First(), strBuilder);
     
    184177
    185178    private string GetToken(ISymbol symbol) {
    186       var tok = InfixExpressionParser.knownSymbols.GetBySecond(symbol).SingleOrDefault();
     179      var tok = InfixExpressionParser.knownSymbols.GetBySecond(symbol).FirstOrDefault();
    187180      if (tok == null)
    188181        throw new ArgumentException(string.Format("Unknown symbol {0} found.", symbol.Name));
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/InfixExpressionParser.cs

    r16356 r16359  
    102102        { "EXP", new Exponential()},
    103103        { "LOG", new Logarithm()},
    104         { "POW", new Power()},
     104        { "POW", new Power() },
    105105        { "ROOT", new Root()},
    106106        { "SQR", new Square() },
Note: See TracChangeset for help on using the changeset viewer.