small things
This commit is contained in:
1 parent
6dd7bda6e4
commit
234c176670
3 files changed
+5
-4
No files matched your search
@@ -1346,14 +1346,13 @@ public class Expression
|
||||
{
|
||||
String operator = pair.getKey();
|
||||
String function = pair.getValue();
|
||||
if ((symbol.equals(operator) || symbol.equals(function)) && node.args.size() > 0)
|
||||
if ((symbol.equals(operator) || symbol.equals(function)) && !node.args.isEmpty())
|
||||
{
|
||||
boolean leftOptimizable = operators.get(operator).isLeftAssoc();
|
||||
ExpressionNode optimizedChild = node.args.get(leftOptimizable ? 0 : (node.args.size() - 1));
|
||||
String type = optimizedChild.token.surface;
|
||||
if ((type.equals(operator) || type.equals(function)) && (!(optimizedChild.op instanceof LazyValue.ContextFreeLazyValue)))
|
||||
{
|
||||
optimized = true;
|
||||
List<ExpressionNode> newargs = new ArrayList<>();
|
||||
if (leftOptimizable)
|
||||
{
|
||||
@@ -1378,6 +1377,7 @@ public class Expression
|
||||
}
|
||||
node.token.morph(Token.TokenType.FUNCTION, function);
|
||||
node.args = newargs;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,6 +346,7 @@ public class Operators
|
||||
return Value.TRUE;
|
||||
});
|
||||
expression.addFunctionalEquivalence("==", "equal");
|
||||
|
||||
expression.addBinaryOperator("!=", precedence.get("equal==!="), false, (v1, v2) ->
|
||||
v1.equals(v2) ? Value.FALSE : Value.TRUE);
|
||||
expression.addFunction("unique", lv -> {
|
||||
|
||||
@@ -56,7 +56,7 @@ public abstract class LazyListValue extends AbstractListValue implements Iterato
|
||||
@Override
|
||||
public String getString()
|
||||
{
|
||||
return String.format(Locale.ROOT, "[%s, %s, ..., %s)", NumericValue.of(start).getString(), NumericValue.of(start + stepp).getString(), NumericValue.of(limit).getString());
|
||||
return String.format(Locale.ROOT, "<%s, %s, ..., %s)", NumericValue.of(start).getString(), NumericValue.of(start + stepp).getString(), NumericValue.of(limit).getString());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public abstract class LazyListValue extends AbstractListValue implements Iterato
|
||||
@Override
|
||||
public String getString()
|
||||
{
|
||||
return String.format(Locale.ROOT, "[%s, %s, ..., %s)", NumericValue.of(start).getString(), NumericValue.of(start + stepp).getString(), NumericValue.of(limit).getString());
|
||||
return String.format(Locale.ROOT, "<%s, %s, ..., %s)", NumericValue.of(start).getString(), NumericValue.of(start + stepp).getString(), NumericValue.of(limit).getString());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user