Closed t-b closed 4 years ago
Remember that -1 is not numeric but an object
Why don‘t you just use (-1)*min(0,1)
the actual problem that you describe is simpler than your example.
min(0,-1)
currently gives
{
"min": [
0,
1
]
}
while
min(0,(-1))
gives
{
"min": [
0,
{
"-": [
1
]
}
]
}
and your formulas are solvable by parentheses
+min(0,(-1))
{
"+": [
{
"min": [
0,
{
"-": [
1
]
}
]
}
]
}
The simplest solution is encapsulating (-[0-9]) and (+[0-9]) by parenthesis in the preparser but that would interfere with operation evaluation.
A similar approach as for the parentheses evaluation would also be possible.
what do you suggest for solving the -1
problems?
Personally, I recommend to always encapsulate -1
in brackets.
currently failing evaluations:
1+-1
{
"+": [
1,
1
]
}
-1*2
{
"-": [
{
"*": [
1,
2
]
}
]
}
2+-1*3
{
"+": [
2,
{
"*": [
1,
3
]
}
]
}
non-first array elements:
[1, 0, -1]
[
1,
0,
1
]
-1 - 1
{
"-": [
1,
1
]
}
-
did not belong to an operation but was evaluated as a numeric prefix[0, 1, 2] [3, 4, 5]
evaluates to
[
0,
1,
2,
[
3,
4,
5
]
]
which is a bit suprising.
That is a bug in the parser. Should we track all issues of the parser here?
It should be of no particular relevance to our use scenario but definitively needs a fix.
I think, such checks for invalid syntax should go to the preparser. But we could probably also catch it in the parser.
The check for the above example would be that GrepString(str, "\]\s*\[")
is invalid
@ukos-git Collecting them here sounds good!
that is not what you expect. Using
58f24b8a (UTF_SweepFormula: Use module definition and make the functions static, 2019-09-21)
.