diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 31f79b1b..bbefe2bc 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -155,9 +155,32 @@ public class TypeUnifyTask extends RecursiveTask>> { } topLevelSets.add(flat); } + return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets)); + + } + + Set> computeCartesianRecursive(Set> fstElems, ArrayList>> sets) { + ArrayList>> newSets = new ArrayList<>(sets); + Set> set = newSets.remove(0); + ArrayList> newSet = new ArrayList<>(set); + Set> result = null; + for(Set a : newSet) { + Set> elems = new HashSet>(fstElems); + elems.add(a); + if (newSets.isEmpty()) { + result = unify2(elems); + } + else { + result = computeCartesianRecursive(elems,newSets); + } + if (!result.isEmpty()) break; + } + return result; + } + + Set> unify2(Set> setToFlatten) { + //Set> setToFlatten = topLevelSets.stream().map(x -> x.iterator().next()).collect(Collectors.toCollection(HashSet::new)); - - Set> setToFlatten = topLevelSets.stream().map(x -> x.iterator().next()).collect(Collectors.toCollection(HashSet::new)); // Cartesian product over all (up to 10) top level sets //Set>> eqPrimeSet = setOps.cartesianProduct(topLevelSets) //.stream().map(x -> new HashSet<>(x)) diff --git a/test/javFiles/Matrix.jav b/test/javFiles/Matrix.jav index e1183535..0133d43c 100644 --- a/test/javFiles/Matrix.jav +++ b/test/javFiles/Matrix.jav @@ -11,13 +11,13 @@ class Matrix extends Vector> { var v2 = new Vector(); var j = 0; while(j < v1.size()) { - var erg = 0; - var k = 0; - while(k < v1.size()) { - erg = erg + v1.elementAt(k) - * m.elementAt(k).elementAt(j); - k++; } - v2.addElement(new Integer(erg)); + //var erg = 0; + //var k = 0; + //while(k < v1.size()) { + //erg = erg + v1.elementAt(k) + // * m.elementAt(k).elementAt(j); + //k++; } + //v2.addElement(new Integer(erg)); j++; } ret.addElement(v2); i++; }