Returns a static positional value for the specified expression. @param expr expression @return positional value or Double#NaN
(final Expr expr)
| 152 | * @return positional value or {@code Double#NaN} |
| 153 | */ |
| 154 | private static double pos(final Expr expr) { |
| 155 | if(expr instanceof final Itr itr) return itr.itr(); |
| 156 | if(Function.LAST.is(expr)) return LAST; |
| 157 | if(expr instanceof final Arith arth && Function.LAST.is(expr.arg(0))) { |
| 158 | final double l = expr.arg(1) instanceof final Itr itr ? itr.itr() : 0; |
| 159 | if(l != 0) return switch(arth.calc) { |
| 160 | case ADD -> LAST + l; |
| 161 | case SUBTRACT -> LAST - l; |
| 162 | case MULTIPLY -> LAST * l; |
| 163 | case DIVIDE -> LAST / l; |
| 164 | default -> Double.NaN; |
| 165 | }; |
| 166 | } |
| 167 | return Double.NaN; |
| 168 | } |
| 169 | |
| 170 | @Override |
| 171 | public boolean equals(final Object obj) { |
no test coverage detected