Created
May 8, 2021 10:05
-
-
Save ice1000/d3e1d13a48949d62d914504c402617f3 to your computer and use it in GitHub Desktop.
Random graph theory problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.List; | |
import java.util.Map; | |
public class Main { | |
interface Level { | |
// Pattern matcher | |
interface Visitor<P, R> { | |
R visitConst(Const c, P p); | |
R visitInfinity(P p); | |
R visitRef(Reference r, P p); | |
} | |
<P, R> R accept(Visitor<P, R> visitor, P p); | |
} | |
record Const(int constant) implements Level { | |
@Override public <P, R> R accept(Visitor<P, R> visitor, P p) { | |
return visitor.visitConst(this, p); | |
} | |
} | |
record Infinity() implements Level { | |
@Override public <P, R> R accept(Visitor<P, R> visitor, P p) { | |
return visitor.visitInfinity(p); | |
} | |
} | |
record Reference(Var ref, int lift) implements Level { | |
@Override public <P, R> R accept(Visitor<P, R> visitor, P p) { | |
return visitor.visitRef(this, p); | |
} | |
} | |
// free means need to be 'solved' | |
record Var(boolean canBeInf, int defaultValue, boolean free) { | |
} | |
record Max(List<Level> levels) { | |
} | |
enum Ord { | |
// <=, >=, == | |
Lt, Gt, Eq | |
} | |
record Equation(Ord ord, Max lhs, Max rhs) { | |
} | |
// in the returned map, all keys are 'free', and the Var in the values' are not 'free' | |
static Map<Var, Level> solve(List<Equation> equations) { | |
// implement | |
throw new UnsupportedOperationException(); | |
} | |
public static void main(String... args) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment