Logic progress
This commit is contained in:
@@ -6,6 +6,11 @@ public enum BinaryOp{
|
||||
mul("*", (a, b) -> a * b),
|
||||
div("/", (a, b) -> a / b),
|
||||
mod("%", (a, b) -> a % b),
|
||||
equal("=", (a, b) -> Math.abs(a - b) < 0.000001 ? 1 : 0),
|
||||
lessThan("<", (a, b) -> a < b ? 1 : 0),
|
||||
lessThanEq("<=", (a, b) -> a <= b ? 1 : 0),
|
||||
greaterThan(">", (a, b) -> a > b ? 1 : 0),
|
||||
greaterThanEq(">=", (a, b) -> a >= b ? 1 : 0),
|
||||
pow("^", Math::pow),
|
||||
shl(">>", (a, b) -> (int)a >> (int)b),
|
||||
shr("<<", (a, b) -> (int)a << (int)b),
|
||||
@@ -13,18 +18,16 @@ public enum BinaryOp{
|
||||
and("and", (a, b) -> (int)a & (int)b),
|
||||
xor("xor", (a, b) -> (int)a ^ (int)b);
|
||||
|
||||
final OpLambda function;
|
||||
final String symbol;
|
||||
public static final BinaryOp[] all = values();
|
||||
|
||||
public final OpLambda function;
|
||||
public final String symbol;
|
||||
|
||||
BinaryOp(String symbol, OpLambda function){
|
||||
this.symbol = symbol;
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
public double get(double a, double b){
|
||||
return function.get(a, b);
|
||||
}
|
||||
|
||||
interface OpLambda{
|
||||
double get(double a, double b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user