Logic progress

This commit is contained in:
Anuken
2020-08-06 12:31:04 -04:00
parent 7482e2a988
commit 5dc78a24e0
30 changed files with 2933 additions and 2582 deletions

View File

@@ -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);
}