Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TypeVar {
- private String name;
- public TypeVar(String nam){
- name = nam;
- }
- public String getName(){
- return name;
- }
- }
- class MLType {
- private TypeVar[][] expression;
- public MLType(TypeVar[][] array){
- expression = new TypeVar[array.length][];
- for(int i = 0; i < array.length; i++){
- expression[i] = new TypeVar[array[i].length];
- for(int j = 0; j < array[i].length; j++){
- expression[i][j] = array[i][j];
- }
- }
- }
- public boolean findVar(TypeVar a){
- for(int i = 0; i<expression.length; i ++){
- for(int j = 0; i<expression[i].length; j++){
- expression[i][j] == a? return true : continue;
- }
- }
- return false;
- }
- public void mustNotDependOn(TypeVar a) throws ItDoesDependOn{
- findVar a? throw(new ItDoesDependOn) : return;
- }
- public String toString(){
- String rtrn = "";
- for(int i=0; i<expression.length; i++){
- if(expression[i].length == 1){
- rtrn += (expression[i].getName());
- }else{
- rtrn += "("
- for(int j=0; j<expression[i].length; j++){
- rtrn += (expression[i][j].getName());
- (j != expression[i].length - 1)? rtrn += "->":rtrn += ")";
- }
- }
- (i != expression.length - 1)?rtrn += "->":continue;
- }
- }
- }
- class ItDoesDependOn extends Exception {
- }
- import java.util.List;
- import java.util.LinkedList;
- class Types {
- private static List<TypeVar> types;
- public static void main(String[] args){
- types = new LinkedList<TypeVar>();
- }
- public static void createNewTypeVar(){
- types.add(new TypeVar("t" + (types.size()+1)));
- }
- public static TypeVar getType(int n){
- return types.get(n-1);
- }
- }
Add Comment
Please, Sign In to add comment