You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+70-4Lines changed: 70 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@
33
33
*[Editing a Matrix example](#editing-a-matrix-example)
34
34
*[12. Finding the characteristic polynomial of a Matrix](#12-finding-the-characteristic-polynomial-of-a-matrix)
35
35
*[Logical Calculus](#logical-calculus)
36
+
*[Expanding Calculus](#expanding-calculus)
36
37
*[TO BE CONTINUED](#to-be-continued)
37
38
38
39
@@ -48,7 +49,7 @@ If you need to access this library via Maven Central, do:
48
49
<dependency>
49
50
<groupId>com.github.gbenroscience</groupId>
50
51
<artifactId>parser-ng</artifactId>
51
-
<version>0.1.8</version>
52
+
<version>0.1.9</version>
52
53
</dependency>
53
54
54
55
@@ -726,8 +727,10 @@ This would give:
726
727
## Logical Calculus
727
728
728
729
The logical expressions in math engine have theirs intentional limitations. Thus allmighty logical expression parser was added around individually evaluated Mathematical expressions which results can be later compared, and logically grouped. The simplest way to evaluate an logical expression in ParserNG is to use the <code>LogicalExpression</code> class.
729
-
<code>LogicalExpression</code> is the class responsible for basic comaprsions and logica expression parsing and evaluation. It calls <code>MathExpression</code> to ech of its basic non-logical parts
730
-
730
+
<code>LogicalExpression</code> is the class responsible for basic comaprsions and logica expression parsing and evaluation. It calls <code>MathExpression</code> to ech of its basic non-logical parts. The default <code>MathExpression</code> can be repalced by any custom implementation of <code>Solvable</code>, but it is only for highly specialized usages. Highlight, where MathExpression is using <code>()</code> for mathematical bracketing, LogicalExpression - as () can be part of underlying comapred mathematical expressiosn uses <code>[]</code> brackets.<br>
731
+
<br>
732
+
In CLI, you can use -l/-L/--logic switch to work with LogicalExpression. Although it is fully compatible with MathExpression you may face unknown issue<br>
Note, that logical parsser supports only dual operators, so where true|false|true is valid, 1<2<3 is invalid!
833
+
Note, that logical parsser's comparsions supports only dual operators, so where true|false|true is valid, 1<2<3 is invalid!
831
834
Thus: [1<2]<3 is necessary and even [[true|false]|true]is recomeded to be used, For 1<2<3 exception is thrown.
832
835
Single letter can logical operands can be used in row. So eg | have same meaning as ||. But also unluckily also eg < is same as <<
833
836
Negation can be done by single ! strictly close attached to [; eg ![true] is ... false. Some spaces like ! [ are actually ok to
@@ -836,6 +839,69 @@ But much less for [r=3;r<r+1 || [r<5]]", which fails and must be declared as "[r
836
839
To avoid this, you can declare all in first dummy expression: "[r=3;r<1] || [r<r+1 || [r<5]]" which ensure theirs allocation ahead of time and do not affect the rest
837
840
If you modify the variables, in the subseqet calls, results maybe funny. Use verbose mode to debug order
838
841
842
+
## Expanding Calculus
843
+
Very often an expressions, or CLI is called above known, huge (generated) array of values. Such can be processed via <code>ExpandingExpression</code>. Unlike other Expressins, this one have List<String> as aditional parameters, where each member is a number. THose numbers can thenbe accessed as L0, L1...Ln. Size of the list is held in special MN variable. The index can be calucalted dynamically, like L{MN/2} - in example of four items, will expand to L2. Although `{}` and `MN` notations are powerfull, the main power is in *slices*:
844
+
```
845
+
Instead of numbers, you can use literalls L0, L1...L99, which you can then call by:
846
+
Ln - vlaue of Nth number
847
+
L2..L4 - will expand to values of L2,L3,L4 - order is hnoured
848
+
L2.. - will expand to values of L2,L3,..Ln-1,Ln
849
+
..L5 - will expand to values of L0,L1...L4,L5
850
+
where ..L5 or L2.. are order sensitive, the L{MN}..L0 or L0..L{MN} is not. But requires dynamic index evaluation
851
+
When used as standalone, VALUES_PNG xor VALUES_IPNG are used to pass in the space separated numbers (the I is inverted order)
852
+
Assume VALUES_PNG='5 9 3 8', then it is the same as VALUES_IPNG='8 3 9 5'; BUt be aware, with I the L.. and ..L are a bit oposite then expected
853
+
L0 then expand to 8; L2.. expands to 9,3,8; ' ..L2 expands to 5,9
854
+
L2..L4 expands to 9,5; L4..L2 expands to 5,9
855
+
```
856
+
ExpandingExpression calls <code>LogicalExpression</code> inside, and yet again the underlying Math evaluator is - defaulting as <code>MathExpression</code> can be repalced by any custom implementation of <code>Solvable</code>. Highlight, where MathExpression is using <code>()</code> for mathematical bracketing, LogicalExpression ses <code>[]</code> brackets. The dynamic indexes in <code>ExpandingExpression</code> uses are wrapped in `{}` <br>
857
+
<br>
858
+
In CLI, you can use -e/-E/--expanding switch to work with Expanding expressions. The array of numbers goes in via VALUES_PNG xor VALUES_IPNG variable. Although it is fully compatible with MathExpression and LogicalExpression you may face unknown issue<br>
See [jenkins-report-generic-chart-column](https://github.com/judovana/jenkins-report-generic-chart-column#most-common-expressions) as real-world user of `ExpandingParser`
Copy file name to clipboardExpand all lines: src/main/java/parser/ExpandingExpression.java
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -98,10 +98,11 @@ public static String getHelp() {
98
98
//longterm todo, repalce this static help by better help using delegated help methods from logical parser
99
99
return"This is abstraction which allows to set with slices, rows and subset of immutable known numbers." + "\n" +
100
100
"Instead of numbers, you can use literalls L0, L1...L99, which you can then call by:" + "\n" +
101
-
"Ln - vlaue of Nth number" + "\n" +
101
+
"Ln - vlaue of Nth number, or in Slices" + "\n" +
102
102
"L2..L4 - will expand to values of L2,L3,L4 - order is hnoured" + "\n" +
103
103
"L2.. - will expand to values of L2,L3,..Ln-1,Ln" + "\n" +
104
104
"..L5 - will expand to values of L0,L1...L4,L5" + "\n" +
105
+
"where ..L5 or L2.. are order sensitive, the L{MN}..L0 or L0..L{MN} is not. But requires dynamic index evaluation." + "\n" +
105
106
"When used as standalone, " + VALUES_PNG + " xor " + VALUES_IPNG + " are used to pass in the space separated numbers (the I is inverted order)" + "\n" +
106
107
"Assume " + VALUES_PNG + "='5 9 3 8', then it is the same as " + VALUES_IPNG + "='8 3 9 5'; BUt be aware, with I the L.. and ..L are a bit oposite then expected" + "\n" +
107
108
"L0 then expand to 8; L2.. expands to 9,3,8; ' ..L2 expands to 5,9 " + "\n" +
@@ -113,12 +114,12 @@ public static String getHelp() {
"Sometimes, Lx, as number is not enough, and you need to calcualte it dynamically. To do so, you can use L{}\n" +
118
119
"Inisde {} can be mathematical formula (including Ls, MN. or even nested {}, which will evaluate itself as number, which will be used as Lx. Eg:\n" +
119
120
"'avg(..L{MN/2}) < avg(L{MN/2}..)' will go to 'avg(..L1) < avg(L1..)' will go on 1 2 3 to 'avg(1,2 ) < avg(2,3) will go to 1.5<2.5 ... true'\n" +
120
121
"For fun try eg: VALUES_PNG='1 2 3' on 'avg(..L{L{MN/2}}) < avg(L{L{MN/2}}..)'\n" +
121
-
"This parser by default uses LogicalExpression interpreter, but should work directly in" + "\n" +
122
+
"This parser by default uses LogicalExpression interpreter, but should work directly on simple Logical or Math expressions. The LogicalExpression class canbe repalced if needed." + "\n" +
122
123
"In verbose mode, the expanded expression is always printed";
0 commit comments