diff --git a/.gitignore b/.gitignore index 17932c3..de04b8c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ replay_pid* **/bin/ .old/ .metadata/ +**/.classpath diff --git a/.metadata/.mylyn/.taskListIndex/segments_1 b/.metadata/.mylyn/.taskListIndex/segments_1 deleted file mode 100644 index 0dff951..0000000 Binary files a/.metadata/.mylyn/.taskListIndex/segments_1 and /dev/null differ diff --git a/.metadata/.mylyn/.taskListIndex/write.lock b/.metadata/.mylyn/.taskListIndex/write.lock deleted file mode 100644 index e69de29..0000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/14/705e7113c9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/14/705e7113c9a1001f17dbd629bd636125 deleted file mode 100644 index 47a8b45..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/14/705e7113c9a1001f17dbd629bd636125 +++ /dev/null @@ -1,5 +0,0 @@ -package abstraction; - -public class Main { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/16/70edcae5d5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/16/70edcae5d5a2001f13baf1c76b2fe20e deleted file mode 100644 index 5bc3d20..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/16/70edcae5d5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr)))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1a/d0738772d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/1a/d0738772d8a2001f13baf1c76b2fe20e deleted file mode 100644 index 7f3ccdf..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1a/d0738772d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,162 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - - boole -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/b05f9b03d6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/b05f9b03d6a2001f13baf1c76b2fe20e deleted file mode 100644 index 5e76658..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/b05f9b03d6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return new Cons(a, this); - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/60a430cfd5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/60a430cfd5a2001f13baf1c76b2fe20e deleted file mode 100644 index 21aa1f9..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/1d/60a430cfd5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,146 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2/b00c6400c9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/2/b00c6400c9a1001f17dbd629bd636125 deleted file mode 100644 index cc4eaa5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2/b00c6400c9a1001f17dbd629bd636125 +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 -org.eclipse.jdt.core.compiler.compliance=21 -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=21 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/25/a084793ad9a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/25/a084793ad9a2001f13baf1c76b2fe20e deleted file mode 100644 index 2212654..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/25/a084793ad9a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,180 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - ILo hhhh = new Cons("b", new Cons("a", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h) - - && t.checkExpect(mstr.sort(new CompStrAlp()), mstr) - && t.checkExpect(hhh.sort(new CompStrAlp()), hhh) - && t.checkExpect(hhhh.sort(new CompStrAlp()), hhh) - - && t.checkExpect(hh.sort(new Comp(new StrLen())), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// Compare the sizes of two things with the given Evaluator. -class Comp implements IComparator { - IEvaluator eval; - Comp(IEvaluator eval) { - this.eval = eval; - } - - public int compare(A a1, A a2) { - return eval.apply(a1) - eval.apply(a2); - } -} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/27/30da8faad6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/27/30da8faad6a2001f13baf1c76b2fe20e deleted file mode 100644 index c44b925..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/27/30da8faad6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,151 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) >= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d09e4d00d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d09e4d00d7a2001f13baf1c76b2fe20e deleted file mode 100644 index c44b925..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d09e4d00d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,151 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) >= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/f02da9a8d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/2e/f02da9a8d8a2001f13baf1c76b2fe20e deleted file mode 100644 index eb1b26c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2e/f02da9a8d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,163 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - ILo hhhh = new Cons("b", new Cons("a", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - - boole -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/70c4a71cc9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/70c4a71cc9a1001f17dbd629bd636125 deleted file mode 100644 index 92a1a7a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/70c4a71cc9a1001f17dbd629bd636125 +++ /dev/null @@ -1,5 +0,0 @@ -package abstraction; - -class Examples { - -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/f0c6b88ed6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/f0c6b88ed6a2001f13baf1c76b2fe20e deleted file mode 100644 index bb0686a..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/2f/f0c6b88ed6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,149 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) >= 0) { - return new Cons(a, new Cons(this.first, this.rest)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/00b7d2dcd7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/00b7d2dcd7a2001f13baf1c76b2fe20e deleted file mode 100644 index c222a70..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/00b7d2dcd7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,155 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3e/b04c2e2a95a6001f1f99f28bbdc62909 b/.metadata/.plugins/org.eclipse.core.resources/.history/3e/b04c2e2a95a6001f1f99f28bbdc62909 deleted file mode 100644 index 6ddb399..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3e/b04c2e2a95a6001f1f99f28bbdc62909 +++ /dev/null @@ -1,131 +0,0 @@ -package fibonacci; - -import tester.Tester; - -class Examples { - - ISequence f; - ISequence a; - ISeqGen aGen = new AGen(); - - void init() { - this.f = new Fibonacci(); - this.a = new GenSeq("", aGen); - } - - void testFibonacci(Tester t) { - init(); - t.checkExpect(f.get(), 0); - t.checkExpect(f.get(), 1); - t.checkExpect(f.get(), 1); - t.checkExpect(f.get(), 2); - t.checkExpect(f.get(), 3); - t.checkExpect(f.get(), 5); - t.checkExpect(f.get(), 8); - } - - void testASeq(Tester t) { - init(); - t.checkExpect(a.get(), ""); - t.checkExpect(a.get(), "a"); - t.checkExpect(a.get(), "aa"); - t.checkExpect(a.get(), "aaa"); - t.checkExpect(a.get(), "aaaa"); - t.checkExpect(a.get(), "aaaaa"); - } -} - -// A generic list. -interface ILo {} - -class Cons implements ILo { - - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } -} - -class Mt implements ILo {} - -interface ISequence { - // Returns the current element in the sequence. - // EFFECT: Updates the state to the next element in the sequence. - X get(); -} - -// Sequence generator method. -interface ISeqGen { - X gen(X state); // Generates the next value in the sequence given the current state. -} - -// The Fibonacci sequence. -class Fibonacci implements ISequence { - - int idx; // Number of times `get()` has been called. - int pre; // The previous (last) number. - int pen; // The penultimate (second to last) number. - - Fibonacci() { - this.pen = 0; - this.pre = 1; - } - - // Get the next in the sequence. - public Integer get() { - int ret; // What to return. - /* - - idx pen pre ret - 0 0 1 0 - 1 0 1 1 - 2 1 1 2 - 3 1 2 3 - 4 2 3 5 - 5 3 5 8 - - */ - - // F(0) = 0; F(1) = 1 - if (this.idx <= 1) ret = this.idx; - else { // F(n) = F(n-1) + F(n-2) - ret = this.pre + this.pen; - - this.pen = this.pre; - this.pre = ret; - } - - this.idx = this.idx + 1; - return ret; - } -} - -// A generic sequence. -class GenSeq implements ISequence { - - X state; // The current state of the sequence. - ISeqGen seqGen; // The method by which new values are generated. - - // Create new generic sequence given an initial state. - GenSeq(X init, ISeqGen seqGen) { - this.state = init; - this.seqGen = seqGen; - } - - public X get() { - X ret = this.state; - this.state = this.seqGen.gen(this.state); - return ret; - } -} - -// A string of n "a"s. -class AGen implements ISeqGen { - - public String gen(String state) { - return state.concat("a"); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3f/70dc808fd7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/70dc808fd7a2001f13baf1c76b2fe20e deleted file mode 100644 index 5a7ffb5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/3f/70dc808fd7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,153 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen(), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4/c08ee01ad6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/4/c08ee01ad6a2001f13baf1c76b2fe20e deleted file mode 100644 index af2c99c..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4/c08ee01ad6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/45/e0cb354ecaa5001f1d5fac7c5024adb1 b/.metadata/.plugins/org.eclipse.core.resources/.history/45/e0cb354ecaa5001f1d5fac7c5024adb1 deleted file mode 100644 index e69de29..0000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/47/e0575f8ad6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/47/e0575f8ad6a2001f13baf1c76b2fe20e deleted file mode 100644 index 93b34b3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/47/e0575f8ad6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,149 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) == 0) { - - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/48/4080d6bbd7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/48/4080d6bbd7a2001f13baf1c76b2fe20e deleted file mode 100644 index e7edeb8..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/48/4080d6bbd7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,155 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new hh.CompStr()), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/48/d0153d80d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/48/d0153d80d7a2001f13baf1c76b2fe20e deleted file mode 100644 index 7775a01..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/48/d0153d80d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,153 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen(), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4c/b083956fcaa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/4c/b083956fcaa1001f17dbd629bd636125 deleted file mode 100644 index 8c2a64f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4c/b083956fcaa1001f17dbd629bd636125 +++ /dev/null @@ -1,94 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean after(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByShortness()).after(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByAlpha()).after(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); - return new StringsAfter(new OrderByAlpha()).after(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/4d/c086d608d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/4d/c086d608d7a2001f13baf1c76b2fe20e deleted file mode 100644 index c44b925..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/4d/c086d608d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,151 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) >= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/53/60620459caa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/53/60620459caa1001f17dbd629bd636125 deleted file mode 100644 index 6b087b4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/53/60620459caa1001f17dbd629bd636125 +++ /dev/null @@ -1,94 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean after(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByShortness()).after(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); - return new StringsAfter(new OrderByAlpha()).after(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/55/10eba5b6d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/55/10eba5b6d7a2001f13baf1c76b2fe20e deleted file mode 100644 index f48fe61..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/55/10eba5b6d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,154 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/56/70843000d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/56/70843000d8a2001f13baf1c76b2fe20e deleted file mode 100644 index 010ab46..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/56/70843000d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,155 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/57/907a27f7d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/57/907a27f7d8a2001f13baf1c76b2fe20e deleted file mode 100644 index ae60648..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/57/907a27f7d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,176 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - ILo hhhh = new Cons("b", new Cons("a", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h) - - && t.checkExpect(mstr.sort(new CompStrAlp()), mstr) - && t.checkExpect(hhh.sort(new CompStrAlp()), hhh) - && t.checkExpect(hhhh.sort(new CompStrAlp()), hhh); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// Compare the sizes of two things with the given Evaluator. -class Comp implements IComparator { - IEvaluator eval; - Comp(IEvaluator eval) { - this.eval = eval; - } - - public int compare() -} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/58/b07536a6d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/58/b07536a6d7a2001f13baf1c76b2fe20e deleted file mode 100644 index e3e6a74..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/58/b07536a6d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,153 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5b/201de412caa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/5b/201de412caa1001f17dbd629bd636125 deleted file mode 100644 index e806c30..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5b/201de412caa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean apply(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByShortness().before(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5b/408f217bd7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/5b/408f217bd7a2001f13baf1c76b2fe20e deleted file mode 100644 index 2c8f0b9..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5b/408f217bd7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5c/c0854747d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/5c/c0854747d8a2001f13baf1c76b2fe20e deleted file mode 100644 index fe0b3c1..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5c/c0854747d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,155 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/5f/203aabc1d6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/5f/203aabc1d6a2001f13baf1c76b2fe20e deleted file mode 100644 index c44b925..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/5f/203aabc1d6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,151 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) >= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/63/00e57d53caa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/63/00e57d53caa1001f17dbd629bd636125 deleted file mode 100644 index 1947461..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/63/00e57d53caa1001f17dbd629bd636125 +++ /dev/null @@ -1,94 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean apply(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByShortness()).apply(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); - return new StringsAfter(new OrderByAlpha()).apply(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/70991c5b19a1001f1cb38ee0d7d0c4d1 b/.metadata/.plugins/org.eclipse.core.resources/.history/6a/70991c5b19a1001f1cb38ee0d7d0c4d1 deleted file mode 100644 index cc4eaa5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6a/70991c5b19a1001f1cb38ee0d7d0c4d1 +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 -org.eclipse.jdt.core.compiler.compliance=21 -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=21 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/0061f8dfd7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/6b/0061f8dfd7a2001f13baf1c76b2fe20e deleted file mode 100644 index 2e91149..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/0061f8dfd7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,155 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt)); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/0095a8d8c9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/6b/0095a8d8c9a1001f17dbd629bd636125 deleted file mode 100644 index c655732..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/6b/0095a8d8c9a1001f17dbd629bd636125 +++ /dev/null @@ -1,89 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByShortness().before(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/70/208ee9e4d5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/70/208ee9e4d5a2001f13baf1c76b2fe20e deleted file mode 100644 index 0f58d86..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/70/208ee9e4d5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr)))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/73/6069c0c4d6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/73/6069c0c4d6a2001f13baf1c76b2fe20e deleted file mode 100644 index 03b8bb3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/73/6069c0c4d6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,151 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) > 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/77/50668705d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/77/50668705d8a2001f13baf1c76b2fe20e deleted file mode 100644 index ff0b2e5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/77/50668705d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,156 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - ILo newsort = sorted.insertSorted(comp, this.first); - return this.rest.sortHelper(comp, newsort); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8/50c70724caa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/8/50c70724caa1001f17dbd629bd636125 deleted file mode 100644 index 7531b56..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8/50c70724caa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean apply(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByAlpha()).apply(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/84/306cebfed5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/84/306cebfed5a2001f13baf1c76b2fe20e deleted file mode 100644 index b965bf5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/84/306cebfed5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/86/30b04fa1d6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/86/30b04fa1d6a2001f13baf1c76b2fe20e deleted file mode 100644 index c44b925..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/86/30b04fa1d6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,151 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) >= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8a/20257291d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/20257291d7a2001f13baf1c76b2fe20e deleted file mode 100644 index 8d52982..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8a/20257291d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,153 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8a/d0c286a6caa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/d0c286a6caa1001f17dbd629bd636125 deleted file mode 100644 index 9146a52..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8a/d0c286a6caa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates an ordering. -class Disorder { - IStringsBefore ordering; - - Disorder(IStringsBefore ordering) { this.ordering = ordering; } - - boolean after(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByShortness()).after(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByAlpha()).after(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByAlpha()).after(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8c/40db7a00d5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/8c/40db7a00d5a2001f13baf1c76b2fe20e deleted file mode 100644 index 7d4adb5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/8c/40db7a00d5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates an ordering. -class Disorder { - IStringsBefore ordering; - - Disorder(IStringsBefore ordering) { this.ordering = ordering; } - - boolean after(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByShortness()).after(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByAlpha()).after(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByOrderkt hi ()).after(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9/70802834caa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/9/70802834caa1001f17dbd629bd636125 deleted file mode 100644 index e806c30..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9/70802834caa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean apply(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByShortness().before(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/94/00d63222d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/94/00d63222d7a2001f13baf1c76b2fe20e deleted file mode 100644 index e8cfb67..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/94/00d63222d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,151 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) <= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/b01fe771d9a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/b01fe771d9a2001f13baf1c76b2fe20e deleted file mode 100644 index b0fe763..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/9c/b01fe771d9a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,180 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - ILo hhhh = new Cons("b", new Cons("a", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h) - - && t.checkExpect(mstr.sort(new CompStrAlp()), mstr) - && t.checkExpect(hhh.sort(new CompStrAlp()), hhh) - && t.checkExpect(hhhh.sort(new CompStrAlp()), hhh) - - && t.checkExpect(hh.sort(new Comp(new StrLen())), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// Compare the sizes of two things with the given Evaluator. -class Comp implements IComparator { - IEvaluator eval; - Comp(IEvaluator eval) { - this.eval = eval; - } - - public int compare(A a1, A a2) { - return eval.apply(a1) - eval.apply(a2); - } -} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/1081b6d0d5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/1081b6d0d5a2001f13baf1c76b2fe20e deleted file mode 100644 index 5bc3d20..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a0/1081b6d0d5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr)))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/60092434d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/60092434d7a2001f13baf1c76b2fe20e deleted file mode 100644 index 55e2b60..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a4/60092434d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,153 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) <= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a5/009f4a1ec9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/009f4a1ec9a1001f17dbd629bd636125 deleted file mode 100644 index 2c94e56..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a5/009f4a1ec9a1001f17dbd629bd636125 +++ /dev/null @@ -1,84 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByShortness().before(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} - -Main.java diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/103b2322d6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/a7/103b2322d6a2001f13baf1c76b2fe20e deleted file mode 100644 index 7ee7362..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/a7/103b2322d6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) == 0) - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/20b1a633d9a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/aa/20b1a633d9a2001f13baf1c76b2fe20e deleted file mode 100644 index 8d414ed..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/aa/20b1a633d9a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,178 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - ILo hhhh = new Cons("b", new Cons("a", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h) - - && t.checkExpect(mstr.sort(new CompStrAlp()), mstr) - && t.checkExpect(hhh.sort(new CompStrAlp()), hhh) - && t.checkExpect(hhhh.sort(new CompStrAlp()), hhh); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// Compare the sizes of two things with the given Evaluator. -class Comp implements IComparator { - IEvaluator eval; - Comp(IEvaluator eval) { - this.eval = eval; - } - - public int compare(A a1, A a2) { - return eval.apply(a1) - eval.apply(a2); - } -} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ae/30548af095a6001f1f99f28bbdc62909 b/.metadata/.plugins/org.eclipse.core.resources/.history/ae/30548af095a6001f1f99f28bbdc62909 deleted file mode 100644 index 59115f4..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ae/30548af095a6001f1f99f28bbdc62909 +++ /dev/null @@ -1,832 +0,0 @@ -package mastermind; - -import java.awt.Color; -import java.awt.Image; -import java.util.Random; -import javalib.funworld.*; -import javalib.worldcanvas.*; -import javalib.worldimages.*; -import tester.Tester; - -class Examples { - - ILoInt noInt = new MtInt(); - ILoInt intsOne = new ConsInt(1, new ConsInt(2, new ConsInt(3, noInt))); - - Dot redDot = new Dot(Color.red), greenDot = new Dot(Color.green), blueDot = - new Dot(Color.blue), reenDot = new Dot(new Color(255, 255, 0)); - - ILoDot noDot = new MtDot(), dotsOne = new ConsDot( - redDot, - new ConsDot(greenDot, new ConsDot(blueDot, noDot)), - new Random(0) - ), dotsTwo = new ConsDot( - redDot, - new ConsDot(blueDot, new ConsDot(blueDot, noDot)) - ), dotsThree = new ConsDot( - reenDot, - new ConsDot(reenDot, new ConsDot(reenDot, noDot)) - ), exampleDotsOne = new ConsDot( - redDot, - new ConsDot( - greenDot, - new ConsDot( - blueDot, - new ConsDot( - greenDot, - new ConsDot(redDot, new ConsDot(greenDot, noDot)) - ) - ) - ) - ), exampleDotsTwo = new ConsDot( - redDot, - new ConsDot( - blueDot, - new ConsDot( - greenDot, - new ConsDot( - greenDot, - new ConsDot(blueDot, new ConsDot(blueDot, noDot)) - ) - ) - ) - ), exampleDotsOneNoExact = new ConsDot( - greenDot, - new ConsDot(blueDot, new ConsDot(redDot, new ConsDot(greenDot, noDot))) - ), exampleDotsTwoNoExact = new ConsDot( - blueDot, - new ConsDot(greenDot, new ConsDot(blueDot, new ConsDot(blueDot, noDot))) - ); - - Feedback exampleFeedback = new Feedback(2, 2); - - Game exampleGame = new Game(); - - boolean testILoDotLen(Tester t) { - return t.checkExpect(noDot.len(), 0) && t.checkExpect(dotsOne.len(), 3); - } - - boolean testILoDotGetnth(Tester t) { - return ( - t.checkException( - new IllegalArgumentException("Index out of bounds."), - noDot, - "get", - 1 - ) && - t.checkException( - new IllegalArgumentException("Index out of bounds."), - dotsOne, - "get", - 3 - ) && - t.checkExpect(dotsOne.get(0), redDot) && - t.checkExpect(dotsOne.get(2), blueDot) - ); - } - - boolean testILoDotGen(Tester t) { - return ( - t.checkExpect(noDot.gen(219), noDot) && - t.checkExpect(dotsOne.gen(1), new ConsDot(redDot, noDot)) && - t.checkExpect( - dotsOne.gen(3), - new ConsDot( - greenDot, - new ConsDot(greenDot, new ConsDot(blueDot, noDot)) - ) - ) - ); - } - - boolean testILoDotIn(Tester t) { - return ( - t.checkExpect(dotsOne.in(blueDot), true) && - t.checkExpect(noDot.in(redDot), false) && - t.checkExpect(dotsThree.in(blueDot), false) - ); - } - - boolean testILoIntRemove(Tester t) { - return ( - t.checkExpect( - intsOne.remove(0), - new ConsInt(2, new ConsInt(3, noInt)) - ) && - t.checkExpect( - intsOne.remove(2), - new ConsInt(1, new ConsInt(2, noInt)) - ) && - t.checkException( - new IllegalArgumentException( - "Index out of bounds: cannot remove something from nothing." - ), - intsOne, - "remove", - 3 - ) && - t.checkException( - new IllegalArgumentException( - "Index out of bounds: cannot remove something from nothing." - ), - noInt, - "remove", - 0 - ) && - t.checkException( - new IllegalArgumentException("Indices must be positive."), - intsOne, - "remove", - -2 - ) - ); - } - - boolean testILoIntLen(Tester t) { - return t.checkExpect(intsOne.len(), 3) && t.checkExpect(noInt.len(), 0); - } - - boolean testILoIntSubOne(Tester t) { - return t.checkExpect( - intsOne.subOne(), - new ConsInt(0, new ConsInt(1, new ConsInt(2, noInt))) - ); - } - - boolean testILoDotExactIndices(Tester t) { - return ( - t.checkException( - new IllegalArgumentException( - "Empty list doesn't exactly match anything." - ), - noDot, - "exactIndices", - noDot - ) && - t.checkExpect( - dotsOne.exactIndices(dotsOne), - new ConsInt(0, new ConsInt(1, new ConsInt(2, noInt))) - ) && - t.checkExpect( - dotsOne.exactIndices(dotsTwo), - new ConsInt(0, new ConsInt(2, new MtInt())) - ) - ); - } - - boolean testILoDotRemove(Tester t) { - return ( - t.checkException( - new IllegalArgumentException("Index out of bounds."), - noDot, - "remove", - 0 - ) && - t.checkExpect( - dotsOne.remove(0), - new ConsDot(greenDot, new ConsDot(blueDot, noDot)) - ) && - t.checkExpect( - dotsTwo.remove(1), - new ConsDot(redDot, new ConsDot(blueDot, noDot)) - ) - ); - } - - boolean testILoDotRemoveAll(Tester t) { - return ( - t.checkExpect(dotsOne.removeAll(noInt), dotsOne) && - t.checkExpect( - dotsOne.removeAll( - new ConsInt(0, new ConsInt(1, new ConsInt(2, noInt))) - ), - noDot - ) && - t.checkExpect(noDot.removeAll(intsOne), noDot) && - t.checkExpect( - dotsTwo.removeAll(new ConsInt(1, new ConsInt(2, noInt))), - new ConsDot(redDot, noDot) - ) - ); - } - - boolean testILoDotCountInexact(Tester t) { - return ( - t.checkExpect(noDot.countInexact(noDot), 0) && - t.checkExpect(dotsOne.countInexact(dotsOne), 3) && - t.checkExpect( - exampleDotsOneNoExact.countInexact(exampleDotsTwoNoExact), - 2 - ) - ); - } - - boolean testILoDotCompare(Tester t) { - return ( - t.checkExpect( - exampleDotsOne.compare(exampleDotsTwo), - exampleFeedback - ) && - t.checkExpect(dotsOne.compare(dotsOne), new Feedback(3, 0)) - ); - } - - boolean testDrawMethods(Tester t) { - // WorldImage incomplete = new IncompleteGuess(exampleDotsOne).draw(); - //WorldImage guesses = new ConsGuess(new Guess(dotsOne, new Feedback(1, 2)), new ConsGuess(new Guess(dotsTwo, new Feedback(2, 5)), new MtGuess())).draw(); - Game game = new Game().addGuess(new Guess(dotsOne, exampleFeedback)); - - WorldImage gameImg = game.draw(); - - int w = (int) gameImg.getWidth(); - int h = (int) gameImg.getHeight(); - - WorldCanvas c = new WorldCanvas(w, h); - WorldScene s = new WorldScene(w, h); - - return game.launch(); - //c.drawScene(s.placeImageXY(gameImg, w/2, h/2)) - //c.drawScene(s.placeImageXY(incomplete, (int) (incomplete.getWidth()/2), 100)) - //c.drawScene(s.placeImageXY(exampleFeedback.draw(), 100, 100)) - //c.drawScene(s.placeImageXY(redDot.draw(), 100, 100)) - //c.drawScene(s.placeImageXY(dotsOne.draw(), 250, 250)) - //&& c.show(); - //true; - } -} - -class Util { - - static int scale = 2; - static int fontSz = 24 * scale; - static int gapW = 4 * scale; // The gap between objects. - - // Drawing methods. - static WorldImage gap = new RectangleImage( - gapW, - gapW, - "outline", - new Color(0, 0, 0, 0) - ); - - static WorldImage pairGap(WorldImage img1, WorldImage img2) { - return new BesideAlignImage(AlignModeY.MIDDLE, img1, gap, img2); - } - - static WorldImage pairGapAbove(WorldImage img1, WorldImage img2) { - return new AboveAlignImage(AlignModeX.CENTER, img1, gap, img2); - } - - static WorldImage strPair(String str1, String str2) { - return pairGap( - new TextImage(str1, fontSz, Color.black), - new TextImage(str2, fontSz, Color.black) - ); - } - - static int pairgapW = 2 * 16 * scale + gapW; -} - -// A game state. -class Game extends World { - - static ILoDot DEFAULTDOTS = new ConsDot( - new Dot(Color.RED), - new ConsDot( - new Dot(Color.GREEN), - new ConsDot(new Dot(Color.BLUE), new MtDot()) - ) - ); - static GameConf DEFAULTCONF = new GameConf(true, 5, 5, DEFAULTDOTS); - - GameConf conf; // The game's configuration. - ILoDot solution; // The solution to the game. - int guessesLeft; // The number of guesses the player has left. - ILoGuess guesses; // The guesses the player has taken. - boolean done; // Is the game over? - boolean won; // Did they player win? - - Game( - GameConf conf, - ILoDot solution, - int guessesLeft, - ILoGuess guesses, - boolean won, - boolean done - ) { - if (this.won && !this.done) throw new IllegalArgumentException( - "Can't win before you've finished playing." - ); - this.conf = conf; - this.solution = solution; - this.won = won; - this.done = done; - this.guessesLeft = guessesLeft; - this.guesses = guesses; - } - - // Convenience constructor using default config and starting values. - Game() { - this( - DEFAULTCONF, - DEFAULTCONF.options.gen(DEFAULTCONF.len), - DEFAULTCONF.nguesses, - new MtGuess(), - false, - false - ); - } - - public WorldScene makeScene() { - WorldScene bg = this.getEmptyScene(); - WorldImage dot = new Dot(Color.RED).draw(); - return bg.placeImageXY( - dot, - (int) dot.getWidth(), - (int) dot.getHeight() - ); - } - - boolean launch() { - return this.bigBang(100, 100); - } - - // Draw the current game state. - WorldImage draw() { - return new AboveAlignImage( - AlignModeX.LEFT, - this.draw_sol(), - this.draw_guesses(), - this.draw_options() - ); - } - - // Draw the solution. - WorldImage draw_sol() { - if (this.done) return this.draw_sol_rev(); - else return this.draw_sol_hid(); - } - - // Draw the revealed answer. - WorldImage draw_sol_rev() { - return this.solution.draw(); - } - - // Draw the hidden answer. - WorldImage draw_sol_hid() { - return new RectangleImage( - this.solution.getW(), - 2 * Dot.r, - OutlineMode.SOLID, - Color.BLACK - ); - } - - WorldImage draw_guesses() { - return this.guesses.draw(); - } - - WorldImage draw_options() { - return this.conf.options.draw(); - } - - // Convenience methods for testing -- not part of program. - Game win() { - return new Game( - this.conf, - this.solution, - this.guessesLeft, - this.guesses, - true, - true - ); - } - - Game addGuess(Guess guess) { - return new Game( - this.conf, - this.solution, - this.guessesLeft, - new ConsGuess(guess, this.guesses), - this.won, - this.done - ); - } -} - -// A game configuration. -class GameConf { - - boolean dups; // Whether duplicates are allowed. - int len; // The length of the sequence to be guessed. - int nguesses; // Number of guesses the player is allowed. - ILoDot options; // The dots of which the solution is comprised. - - GameConf(boolean dups, int len, int nguesses, ILoDot options) { - if (len <= 0) throw new IllegalArgumentException( - "Length of the solution must be greater than 0." - ); - if (nguesses <= 0) throw new IllegalArgumentException( - "Must provide the player some guesses." - ); - int oplen = options.len(); - if (oplen <= 0) throw new IllegalArgumentException( - "Must have dot options to guess with." - ); - if (!dups && len > oplen) throw new IllegalArgumentException( - "Cant create solution of that length without duplicates." - ); - - this.dups = dups; - this.len = len; - this.nguesses = nguesses; - this.options = options; - } -} - -// A list of guesses. -interface ILoGuess { - WorldImage draw(); -} - -class ConsGuess implements ILoGuess { - - Guess guess; - ILoGuess nxt; - - ConsGuess(Guess guess, ILoGuess nxt) { - this.guess = guess; - this.nxt = nxt; - } - - public WorldImage draw() { - return Util.pairGapAbove(guess.draw(), this.nxt.draw()); - } -} - -class MtGuess implements ILoGuess { - - public WorldImage draw() { - return new EmptyImage(); - } -} - -// A guess. -class Guess { - - ILoDot guess; // The dots the user entered. - Feedback feedback; // The feedback returned. - - Guess(ILoDot guess, Feedback feedback) { - this.guess = guess; - this.feedback = feedback; - } - - WorldImage draw() { - return Util.pairGap(this.guess.draw(), this.feedback.draw()); - } -} - -// A guess in the midst of being entered. -class IncompleteGuess { - - ILoDot guessSoFar; - - IncompleteGuess(ILoDot guessSoFar) { - this.guessSoFar = guessSoFar; - } - - WorldImage draw() { - return guessSoFar.draw(); - } -} - -// Feedback for a guess. -class Feedback { - - int exact, inexact; - - Feedback(int exact, int inexact) { - this.exact = exact; - this.inexact = inexact; - } - - Feedback add(Feedback other) { - int otherExact = other.exact, otherInexact = other.inexact; - - return new Feedback( - this.exact + otherExact, - this.inexact + otherInexact - ); - } - - WorldImage draw() { - return Util.strPair( - String.valueOf(this.exact), - String.valueOf(this.exact) - ); - } -} - -// A list of dots. -interface ILoDot { - int len(); // Get length. - Dot get(int n); // Get nth element. - ILoDot remove(int n); // Remove nth element. - ILoDot removeAll(ILoInt indices); // Remove element at each index. - ILoDot gen(int n); // Generate randomized list. - - boolean match(Color col); // Do the colors match? - boolean in(Dot dot); // Is the dot in here? - - Feedback compare(ILoDot other); // Compare two lists & give feedback. - ILoInt exactIndices(ILoDot other); // Get indices of exact matches. - ILoInt exactIndicesHelper(ILoDot other, int i); - int countInexact(ILoDot other); // Get the number of inexact matches. Must be fed exact match-free lists to be accurate. - int countInexactHelper(ILoDot other, ILoDot seen); - - WorldImage draw(); // Draw the dots. - int getW(); // Get the total width, in pixels, of the list. -} - -class ConsDot implements ILoDot { - - Random rand; - Dot dot; - ILoDot nxt; - - ConsDot(Dot dot, ILoDot nxt, Random rand) { - this.rand = rand; - this.dot = dot; - this.nxt = nxt; - } - - ConsDot(Dot dot, ILoDot nxt) { - this(dot, nxt, new Random()); - } - - public ILoDot gen(int n) { - return n <= 0 - ? new MtDot() - : new ConsDot( - this.get(this.rand.nextInt(this.len())), - this.gen(n - 1) - ); - } - - public Dot get(int n) { - if (n == 0) return this.dot; - else return this.nxt.get(n - 1); - } - - public boolean in(Dot dot) { - return dot.equals(this.dot) || this.nxt.in(dot); - } - - public int len() { - return 1 + this.nxt.len(); - } - - public boolean match(Color col) { - return col.equals(this.dot.c); - } - - public WorldImage draw() { - return new BesideAlignImage( - AlignModeY.PINHOLE, - this.dot.draw(), - Util.gap, - this.nxt.draw() - ); - } - - public int getW() { - return this.len() * Dot.r * 2; - } - - public Feedback compare(ILoDot other) { - if (this.len() != other.len()) throw new IllegalArgumentException( - "Cannot compare different lengthed lists." - ); - - ILoInt exactIndices = this.exactIndices(other); - - ILoDot thisWithoutExact = this.removeAll(exactIndices); - ILoDot otherWithoutExact = other.removeAll(exactIndices); - - int exact = exactIndices.len(); - int inexact = thisWithoutExact.countInexact(otherWithoutExact); - - return new Feedback(exact, inexact); - } - - public ILoInt exactIndices(ILoDot other) { - return this.exactIndicesHelper(other, 0); - } - - public ILoInt exactIndicesHelper(ILoDot other, int i) { - // Stop after reaching the end of the list. - if (i == this.len()) return new MtInt(); - - return this.get(i).equals(other.get(i)) - ? new ConsInt(i, this.exactIndicesHelper(other, i + 1)) - : this.exactIndicesHelper(other, i + 1); - } - - public int countInexact(ILoDot other) { - return this.countInexactHelper(other, new MtDot()); - } - - public int countInexactHelper(ILoDot other, ILoDot seen) { - if (seen.in(this.dot)) { - return this.nxt.countInexactHelper( - other, - new ConsDot(this.dot, seen) - ); - } - - return ( - (other.in(this.dot) ? 1 : 0) + - this.nxt.countInexactHelper(other, new ConsDot(this.dot, seen)) - ); - } - - public ILoDot remove(int n) { - if (n < 0) throw new IllegalArgumentException( - "Indices must be positive." - ); - - if (n == 0) return this.nxt; - else return new ConsDot(this.dot, this.nxt.remove(n - 1)); - } - - public ILoDot removeAll(ILoInt indices) { - if (indices.isEmpty()) return this; - return this.remove(indices.first()).removeAll(indices.rest().subOne()); - } -} - -class MtDot implements ILoDot { - - public ILoDot gen(int n) { - return new MtDot(); - } - - public Dot get(int n) { - throw new IllegalArgumentException("Index out of bounds."); - } - - public int len() { - return 0; - } - - public WorldImage draw() { - return new EmptyImage(); - } - - public int getW() { - return 0; - } - - public Feedback compare(ILoDot other) { - return new Feedback(0, 0); - } - - public boolean match(Color col) { - return false; - } - - public boolean in(Dot dot) { - return false; - } - - public ILoInt exactIndices(ILoDot other) { - throw new IllegalArgumentException( - "Empty list doesn't exactly match anything." - ); - } - - public ILoInt exactIndicesHelper(ILoDot other, int i) { - return new MtInt(); - } - - public int countInexact(ILoDot other) { - return 0; - } - - public int countInexactHelper(ILoDot other, ILoDot seen) { - return 0; - } - - public ILoDot remove(int n) { - throw new IllegalArgumentException("Index out of bounds."); - } - - public ILoDot removeAll(ILoInt indices) { - return this; - } -} - -// A dot. -class Dot { - - static int r = 16 * Util.scale; - static OutlineMode outlineMode = OutlineMode.SOLID; - - Color c; - - Dot(Color c) { - this.c = c; - } - - // Draw the dot. - WorldImage draw() { - return new CircleImage(r, outlineMode, this.c); - } - - // Get the width of the dot. - int getW() { - return 2 * r; - } -} - -// A list of integers. -interface ILoInt { - int len(); // Get the length of the list. - ILoInt remove(int n); // Remove the nth element of the list. - boolean isEmpty(); // Is it empty? - int first(); // Get the first value. - ILoInt rest(); // Get the rest value. - ILoInt subOne(); // Subtract 1 from every int. -} - -class ConsInt implements ILoInt { - - int val; - ILoInt nxt; - - ConsInt(int val, ILoInt nxt) { - this.val = val; - this.nxt = nxt; - } - - public int len() { - return 1 + this.nxt.len(); - } - - public ILoInt remove(int n) { - if (n < 0) throw new IllegalArgumentException( - "Indices must be positive." - ); - return n == 0 - ? this.nxt - : new ConsInt(this.val, this.nxt.remove(n - 1)); - } - - public boolean isEmpty() { - return false; - } - - public int first() { - return this.val; - } - - public ILoInt rest() { - return this.nxt; - } - - public ILoInt subOne() { - return new ConsInt(this.val - 1, this.nxt.subOne()); - } -} - -class MtInt implements ILoInt { - - public int len() { - return 0; - } - - public ILoInt remove(int n) { - throw new IllegalArgumentException( - "Index out of bounds: cannot remove something from nothing." - ); - } - - public boolean isEmpty() { - return true; - } - - public int first() { - throw new IllegalArgumentException( - "Cannot get first element in a list without any." - ); - } - - public ILoInt rest() { - throw new IllegalArgumentException("Cannot get rest of empty list."); - } - - public ILoInt subOne() { - return this; - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/8099c438caa5001f1d5fac7c5024adb1 b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/8099c438caa5001f1d5fac7c5024adb1 deleted file mode 100644 index cc4eaa5..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/8099c438caa5001f1d5fac7c5024adb1 +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 -org.eclipse.jdt.core.compiler.compliance=21 -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=21 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/b07254e5c9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/b07254e5c9a1001f17dbd629bd636125 deleted file mode 100644 index e0bcc78..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b0/b07254e5c9a1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean apply(String s1, String s2) { - return ! this.ordering(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByShortness().before(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b1/20e416e9d5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/b1/20e416e9d5a2001f13baf1c76b2fe20e deleted file mode 100644 index a4b8402..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b1/20e416e9d5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr)))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b1/6045e1f2d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/b1/6045e1f2d8a2001f13baf1c76b2fe20e deleted file mode 100644 index be87018..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b1/6045e1f2d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,174 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - ILo hhhh = new Cons("b", new Cons("a", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h) - - && t.checkExpect(mstr.sort(new CompStrAlp()), mstr) - && t.checkExpect(hhh.sort(new CompStrAlp()), hhh) - && t.checkExpect(hhhh.sort(new CompStrAlp()), hhh); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// Compare the sizes of two things with the given Evaluator. -class Comp implements IComparator { - IEvaluator eval; - Comp(IEvaluator eval) { - this.eval = eval; - } -} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b1/90319d7cbda2001f15f3ea04fc682a70 b/.metadata/.plugins/org.eclipse.core.resources/.history/b1/90319d7cbda2001f15f3ea04fc682a70 deleted file mode 100644 index 7a9e0d9..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b1/90319d7cbda2001f15f3ea04fc682a70 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates an ordering. -class Disorder { - IStringsBefore ordering; - - Disorder(IStringsBefore ordering) { this.ordering = ordering; } - - boolean after(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByShortness()).after(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByAlpha()).after(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByOrder()).after(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/509e7e76caa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/509e7e76caa1001f17dbd629bd636125 deleted file mode 100644 index 7864742..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/509e7e76caa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean after(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByShortness()).after(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByAlpha()).after(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByAlpha()).after(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b5/d0dd3cd3d5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/b5/d0dd3cd3d5a2001f13baf1c76b2fe20e deleted file mode 100644 index 5bc3d20..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b5/d0dd3cd3d5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr)))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b7/00975a60d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/b7/00975a60d8a2001f13baf1c76b2fe20e deleted file mode 100644 index 704e17f..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b7/00975a60d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,160 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/606810c5c9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/b8/606810c5c9a1001f17dbd629bd636125 deleted file mode 100644 index 5aab356..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/b8/606810c5c9a1001f17dbd629bd636125 +++ /dev/null @@ -1,82 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByShortness().before(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/3035bce4d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/3035bce4d8a2001f13baf1c76b2fe20e deleted file mode 100644 index f330e18..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/3035bce4d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,166 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - ILo hhhh = new Cons("b", new Cons("a", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h) - - && t.checkExpect(mstr.sort(new CompStrAlp()), mstr) - && t.checkExpect(hhh.sort(new CompStrAlp()), hhh) - && t.checkExpect(hhhh.sort(new CompStrAlp()), hhh); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0f4c33ecaa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0f4c33ecaa1001f17dbd629bd636125 deleted file mode 100644 index 6481e47..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0f4c33ecaa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean apply(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsBefore(new OrderByShortness()).apply(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c5/007f5fdad5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/c5/007f5fdad5a2001f13baf1c76b2fe20e deleted file mode 100644 index 5bc3d20..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/c5/007f5fdad5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr)))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/100a2307c9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/100a2307c9a1001f17dbd629bd636125 deleted file mode 100644 index e69de29..0000000 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/b0dff607d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/b0dff607d8a2001f13baf1c76b2fe20e deleted file mode 100644 index 6cad6e1..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/b0dff607d8a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,156 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - ILo newsort = sorted.insertSorted(comp, this.first); - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/db/c051ac7fcaa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/db/c051ac7fcaa1001f17dbd629bd636125 deleted file mode 100644 index 2df2340..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/db/c051ac7fcaa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean after(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByShortness()).after(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByAlpha()).after(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return new Disorder(new OrderByAlpha()).after(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/df/20e4d12e95a6001f1f99f28bbdc62909 b/.metadata/.plugins/org.eclipse.core.resources/.history/df/20e4d12e95a6001f1f99f28bbdc62909 deleted file mode 100644 index 1a5d152..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/df/20e4d12e95a6001f1f99f28bbdc62909 +++ /dev/null @@ -1,130 +0,0 @@ -package fibonacci; - -import tester.Tester; - -class Examples { - - ISequence f; - ISequence a; - ISeqGen aGen = new AGen(); - - void init() { - this.f = new Fibonacci(); - this.a = new GenSeq("", aGen); - } - - void testFibonacci(Tester t) { - init(); - t.checkExpect(f.get(), 0); - t.checkExpect(f.get(), 1); - t.checkExpect(f.get(), 1); - t.checkExpect(f.get(), 2); - t.checkExpect(f.get(), 3); - t.checkExpect(f.get(), 5); - t.checkExpect(f.get(), 8); - } - - void testASeq(Tester t) { - init(); - t.checkExpect(a.get(), ""); - t.checkExpect(a.get(), "a"); - t.checkExpect(a.get(), "aa"); - t.checkExpect(a.get(), "aaa"); - t.checkExpect(a.get(), "aaaa"); - t.checkExpect(a.get(), "aaaaa"); - } -} - -// A generic list. -interface ILo {} - -class Cons implements ILo { - - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } -} - -class Mt implements ILo {} - -interface ISequence { - // Returns the current element in the sequence. - // EFFECT: Updates the state to the next element in the sequence. - X get(); -} - -// Sequence generator method. -interface ISeqGen { - X gen(X state); // Generates the next value in the sequence given the current state. -} - -// The Fibonacci sequence. -class Fibonacci implements ISequence { - - int idx; // Number of times `get()` has been called. - int pre; // The previous (last) number. - int pen; // The penultimate (second to last) number. - - Fibonacci() { - this.pen = 0; - this.pre = 1; - } - - // Get the next in the sequence. - public Integer get() { - int ret; // What to return. - /* - - idx pen pre ret - 0 0 1 0 - 1 0 1 1 - 2 1 1 2 - 3 1 2 3 - 4 2 3 5 - 5 3 5 8 - - */ - - // F(0) = 0; F(1) = 1 - if (this.idx <= 1) ret = this.idx; - else { // F(n) = F(n-1) + F(n-2) - ret = this.pre + this.pen; - - this.pen = this.pre; - this.pre = ret; - } - - this.idx = this.idx + 1; - return ret; - } -} - -// A generic sequence. -class GenSeq implements ISequence { - - X state; // The current state of the sequence. - ISeqGen seqGen; // The method by which new values are generated. - - // Create new generic sequence given an initial state. - GenSeq(X init, ISeqGen seqGen) { - this.state = init; - this.seqGen = seqGen; - } - - public X get() { - X ret = this.state; - this.state = this.seqGen.gen(this.state); - return ret; - } -} - -// A string of n "a"s. -class AGen implements ISeqGen { - - public String gen(String state) { - return state.concat("a"); - }} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/df/d0a5984dcaa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/df/d0a5984dcaa1001f17dbd629bd636125 deleted file mode 100644 index bec6d90..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/df/d0a5984dcaa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean apply(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByShortness()).apply(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e/c0b41b9bd6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/e/c0b41b9bd6a2001f13baf1c76b2fe20e deleted file mode 100644 index 4196669..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e/c0b41b9bd6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,149 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) >= 0) { - return new Cons(a, this); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/a0052e21d6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/a0052e21d6a2001f13baf1c76b2fe20e deleted file mode 100644 index db70c78..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e1/a0052e21d6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first)) - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e4/f0f0a1ead5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/e4/f0f0a1ead5a2001f13baf1c76b2fe20e deleted file mode 100644 index 242814e..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e4/f0f0a1ead5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e6/00802f0bd9a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/e6/00802f0bd9a2001f13baf1c76b2fe20e deleted file mode 100644 index 94eb4f0..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e6/00802f0bd9a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,176 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - ILo hh = new Cons("hh", new Cons("hhhh", new Cons("h", mstr))); - ILo hhh = new Cons("a", new Cons("b", new Cons("c", mstr))); - ILo hhhh = new Cons("b", new Cons("a", new Cons("c", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - - boolean testILoSort(Tester t) { - return t.checkExpect(h.sort(new CompStrLen()), h) - && t.checkExpect(mstr.sort(new CompStrLen()), mstr) - && t.checkExpect(helloWorld.sort(new CompStrLen()), new Cons("world.", new Cons("Hello, ", mstr))) - && t.checkExpect(hh.sort(new CompStrLen()), h) - - && t.checkExpect(mstr.sort(new CompStrAlp()), mstr) - && t.checkExpect(hhh.sort(new CompStrAlp()), hhh) - && t.checkExpect(hhhh.sort(new CompStrAlp()), hhh); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// Compare strings alphabetically. -class CompStrAlp implements IComparator { public int compare(String s1, String s2) { - return s1.compareTo(s2); -}} - -// Compare the sizes of two things with the given Evaluator. -class Comp implements IComparator { - IEvaluator eval; - Comp(IEvaluator eval) { - this.eval = eval; - } - - public int compare() -} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return this.rest.sortHelper(comp, new Cons(this.first, new Mt())); - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return this.rest.sortHelper(comp, sorted.insertSorted(comp, this.first)); - } - - public ILo insertSorted(IComparator comp, A a) { - return comp.compare(a, this.first) <= 0 ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/40be406dcaa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/e7/40be406dcaa1001f17dbd629bd636125 deleted file mode 100644 index 5606413..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/e7/40be406dcaa1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean after(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByShortness()).after(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return new StringsAfter(new OrderByAlpha()).after(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/f0427239caa1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/f0427239caa1001f17dbd629bd636125 deleted file mode 100644 index d94e2b2..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ea/f0427239caa1001f17dbd629bd636125 +++ /dev/null @@ -1,94 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - boolean apply(String s1, String s2) { - return ! this.ordering.before(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByShortness().before(s1, s2); - return new StringsBefore(new OrderByShortness()).apply(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/70b55cebd5a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/70b55cebd5a2001f13baf1c76b2fe20e deleted file mode 100644 index 0309341..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/eb/70b55cebd5a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,147 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello))); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - return null; - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ee/20654556caa5001f1d5fac7c5024adb1 b/.metadata/.plugins/org.eclipse.core.resources/.history/ee/20654556caa5001f1d5fac7c5024adb1 deleted file mode 100644 index fc96fc3..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/ee/20654556caa5001f1d5fac7c5024adb1 +++ /dev/null @@ -1,5 +0,0 @@ -package fibonacci; - -public class Main { - -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/a09bc128d7a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/a09bc128d7a2001f13baf1c76b2fe20e deleted file mode 100644 index 5346f57..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f3/a09bc128d7a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,153 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) <= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - - return comp.compare(a, this.first) ? new Cons(a ,this) : new Cons(this.first, this.rest.insertSorted(comp, a)); - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/c04072dfc9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/c04072dfc9a1001f17dbd629bd636125 deleted file mode 100644 index 2cdffca..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f5/c04072dfc9a1001f17dbd629bd636125 +++ /dev/null @@ -1,93 +0,0 @@ -package abstraction; - -import tester.Tester; - -class Examples { - ILoStrings someWords = new ConsString("feldspar", new ConsString("assignment", new ConsString("curb", new LastString("carpet")))); - - boolean tests(Tester t) { - return t.checkExpect(someWords.earliest(new OrderByShortness()), "curb") - && t.checkExpect(someWords.earliest(new OrderByAlpha()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByOrder()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByLongness()), "assignment") - && t.checkExpect(someWords.earliest(new OrderByUnalpha()), "feldspar") - && t.checkExpect(someWords.earliest(new OrderByDisorder()), "carpet"); - } -} - -interface IStringsBefore { - boolean before(String s1, String s2); -} - -// Negates a IStringsBefore. -class StringsAfter { - IStringsBefore ordering; - - StringsAfter(IStringsBefore ordering) { this.ordering = ordering; } - - apply(String s1, String s2) { - return ! this.ordering(s1, s2); - } -} - -class OrderByShortness implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.length() <= s2.length(); -}} - -class OrderByAlpha implements IStringsBefore { public boolean before(String s1, String s2) { - return s1.compareTo(s2) <= 0; -}} - -class OrderByOrder implements IStringsBefore { public boolean before(String s1, String s2) { - return true; -}} - -class OrderByLongness implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByShortness().before(s1, s2); -}} - -class OrderByUnalpha implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByAlpha().before(s1, s2); -}} - -class OrderByDisorder implements IStringsBefore { public boolean before(String s1, String s2) { - return ! new OrderByOrder().before(s1, s2); -}} - -// A non-empty list of strings. -interface ILoStrings { - String val(); // Gets the value. - String earliest(IStringsBefore ordering); // Gets the earliest in a list of strings. - String earliestHelper(IStringsBefore ordering, String prev); -} - -abstract class ALoStrings implements ILoStrings { - String val; - - ALoStrings(String val) { this.val = val; } - - public String val() { return this.val; } -} - -class ConsString extends ALoStrings { - ILoStrings nxt; - - ConsString(String val, ILoStrings nxt) { - super(val); - this.nxt = nxt; - } - - public String earliest(IStringsBefore ordering) { - return ordering.before(this.val, this.nxt.val()) ? this.nxt.earliestHelper(ordering, this.val) : this.nxt.earliest(ordering); - } - - public String earliestHelper(IStringsBefore ordering, String prev) { - return new ConsString(prev, this.nxt).earliest(ordering); - } -} - -class LastString extends ALoStrings { - LastString(String val) { super(val); } - public String earliest(IStringsBefore ordering) { return this.val; } - public String earliestHelper(IStringsBefore ordering, String prev) { return prev; } -} \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f9/f0558abfd6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/f9/f0558abfd6a2001f13baf1c76b2fe20e deleted file mode 100644 index e8cfb67..0000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.history/f9/f0558abfd6a2001f13baf1c76b2fe20e +++ /dev/null @@ -1,151 +0,0 @@ -package generics; - -import tester.Tester; - -class Examples { - ILo mint = new Mt(); - ILo lint = new Cons(1, new Cons(92, new Cons(-12, mint))); - ILo lint2 = new Cons(1, new Cons(1, mint)); - - ILo mstr = new Mt(); - ILo hello = new Cons("Hello, ", mstr); - ILo world = new Cons("world.", mstr); - ILo ajcmsdj = new Cons("ajcmsdj", mstr); - ILo helloWorld = new Cons("Hello, ", new Cons("world.", mstr)); - ILo helloAjcmsdj = new Cons("Hello, ", ajcmsdj); - ILo h = new Cons("h", new Cons("hh", new Cons("hhhh", mstr))); - - boolean testILoAppend(Tester t) { - return t.checkExpect(hello.append(world), helloWorld) && - t.checkExpect(lint.append(mint), lint) && - t.checkExpect(mint.append(lint), lint); - } - - boolean testILoArmax(Tester t) { - return t.checkExpect(helloWorld.argmax(new StrLen()), "Hello, ") - && t.checkExpect(helloAjcmsdj.argmax(new StrLen()), "Hello, ") - && t.checkExpect(lint2.argmax(new IntSize()), 1) - && t.checkExpect(lint.argmax(new IntSize()), 92); - } - - boolean testILoInsertSorted(Tester t) { - return t.checkExpect(mstr.insertSorted(new CompStrLen(), "h"), new Cons("h", mstr)) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "s"), new Cons("s", hello)) - && t.checkExpect(h.insertSorted(new CompStrLen(), "hhh"), new Cons("h", new Cons("hh", new Cons("hhh", new Cons("hhhh", mstr))))) - && t.checkExpect(hello.insertSorted(new CompStrLen(), "hello"), new Cons("hello", hello)); - } - -} - -// Generic function. -interface IFunc { - Y apply(X input); -} - -// Extracts the value of an input. -interface IEvaluator extends IFunc {} - -// Calculate the length of a string. -class StrLen implements IEvaluator { public Integer apply(String input) { - return input.length(); -}} - -// Calculate the size of an integer. -class IntSize implements IEvaluator { public Integer apply(Integer input) { - return input; -}} - -// Compares two values. -interface IComparator { - // Returns a negative number if a1 is "smaller" than a2, - // 0 if they are considered equal, - // and a positive number of a1 is "bigger" than a2. - int compare(A a1, A a2); -} - -// Compare string lengths. -class CompStrLen implements IComparator { public int compare(String s1, String s2) { - return s1.length() - s2.length(); -}} - -// A list of A. -interface ILo { - // Append a list. - ILo append(ILo a); - // Find the largest from the evaluator. - A argmax(IEvaluator eval); - A argmaxHelper(IEvaluator eval, A prev, Integer prevVal); - // Skip this element of the list. - ILo skip(); - // Sort the list with the comparator. - ILo sort(IComparator comp); - ILo sortHelper(IComparator comp, ILo sorted); - // Add an element to the correct place in a sorted list. - ILo insertSorted(IComparator comp, A a); -} - -class Cons implements ILo { - A first; - ILo rest; - - Cons(A first, ILo rest) { - this.first = first; - this.rest = rest; - } - - public ILo append(ILo a) { return new Cons(this.first, this.rest.append(a)); } - - public A argmax(IEvaluator eval) { - return argmaxHelper(eval, this.first, eval.apply(this.first)); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - A now = this.first; - Integer nowVal = eval.apply(now); - - return prevVal >= nowVal ? - this.rest.argmaxHelper(eval, prev, prevVal) : - this.rest.skip().argmaxHelper(eval, now, nowVal); - }; - - public ILo skip() { - return this.rest; - } - - public ILo sort(IComparator comp) { - return null; - } - - public ILo sortHelper(IComparator comp, ILo sorted) { - return null; - } - - public ILo insertSorted(IComparator comp, A a) { - if (comp.compare(a, this.first) <= 0) { - return new Cons(a, this); - } else { - return new Cons(this.first, this.rest.insertSorted(comp, a)); - } - } -} - -class Mt implements ILo { - public ILo append(ILo a) { return a; } - public A argmax(IEvaluator eval) { - throw new UnsupportedOperationException("No max of empty list."); - } - - public A argmaxHelper(IEvaluator eval, A prev, Integer prevVal) { - return prev; - } - - public ILo skip() { return this; } - - public ILo sort(IComparator comp) { return this; } - public ILo sortHelper(IComparator comp, ILo sorted) { - return sorted; - } - public ILo insertSorted(IComparator comp, A a) { - return new Cons(a, this); - } -} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location b/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location index 5eade1a..fa0feae 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location and b/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/af/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/af/history.index deleted file mode 100644 index 6baa17a..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/af/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/e4/5a/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/e4/5a/history.index deleted file mode 100644 index d5d1699..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/e4/5a/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.egit.core/GitProjectData.properties index 727cb73..b11561f 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.egit.core/GitProjectData.properties +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.egit.core/GitProjectData.properties @@ -1,3 +1,3 @@ #GitProjectData -#Wed Nov 13 09:09:56 EST 2024 +#Thu Nov 21 00:04:34 EST 2024 .gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.jdt.core/state.dat index 92d1657..ac7df77 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.jdt.core/state.dat and b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.egit.core/GitProjectData.properties index aef0f88..b11561f 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.egit.core/GitProjectData.properties +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.egit.core/GitProjectData.properties @@ -1,3 +1,3 @@ #GitProjectData -#Tue Nov 05 15:25:59 EST 2024 +#Thu Nov 21 00:04:34 EST 2024 .gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.jdt.core/state.dat index 757bc2d..58656ce 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.jdt.core/state.dat and b/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/af/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/af/history.index deleted file mode 100644 index 5a9e1a7..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/af/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/e4/da/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/e4/da/history.index deleted file mode 100644 index 1503766..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/e4/da/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.egit.core/GitProjectData.properties index 75ea3ea..b11561f 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.egit.core/GitProjectData.properties +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.egit.core/GitProjectData.properties @@ -1,3 +1,3 @@ #GitProjectData -#Mon Nov 18 11:29:02 EST 2024 +#Thu Nov 21 00:04:34 EST 2024 .gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.jdt.core/state.dat index 2c3e2b9..21b12ab 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.jdt.core/state.dat and b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/af/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/af/history.index deleted file mode 100644 index a8c0f93..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/af/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/e4/7c/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/e4/7c/history.index deleted file mode 100644 index 1f630b2..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/e4/7c/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.egit.core/GitProjectData.properties index b94d40b..b11561f 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.egit.core/GitProjectData.properties +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.egit.core/GitProjectData.properties @@ -1,3 +1,3 @@ #GitProjectData -#Tue Nov 12 12:12:54 EST 2024 +#Thu Nov 21 00:04:34 EST 2024 .gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.jdt.core/state.dat index d2399c5..b84cefc 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.jdt.core/state.dat and b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/e4/4c/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/e4/4c/history.index deleted file mode 100644 index 419d37c..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/e4/4c/history.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.location b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.location deleted file mode 100644 index 761f0a0..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.location and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers deleted file mode 100644 index 772679a..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.egit.core/GitProjectData.properties index 96fd897..b11561f 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.egit.core/GitProjectData.properties +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.egit.core/GitProjectData.properties @@ -1,3 +1,3 @@ #GitProjectData -#Mon Nov 04 20:43:42 EST 2024 +#Thu Nov 21 00:04:34 EST 2024 .gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.jdt.core/state.dat index ce2ffff..2fc8b61 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.jdt.core/state.dat and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.egit.core/GitProjectData.properties index f2a0665..b11561f 100644 --- a/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.egit.core/GitProjectData.properties +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.egit.core/GitProjectData.properties @@ -1,3 +1,3 @@ #GitProjectData -#Tue Nov 05 16:24:07 EST 2024 +#Thu Nov 21 00:04:34 EST 2024 .gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.jdt.core/state.dat index 02994e5..f10b143 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.jdt.core/state.dat and b/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index index 9d5973b..54ab559 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index and b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/17.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/17.tree deleted file mode 100644 index bd3fa66..0000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/17.tree and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources index 9650df2..ceb229c 100644 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.vrapper.eclipse.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.vrapper.eclipse.prefs deleted file mode 100644 index 139c2a4..0000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.vrapper.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -vrapperEnabled=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ant.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ant.ui.prefs deleted file mode 100644 index 565f933..0000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ant.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -useAnnotationsPrefPage=true -useQuickDiffPrefPage=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs index 30841eb..bdd6a56 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 encoding=UTF-8 +refresh.lightweight.enabled=true version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs deleted file mode 100644 index 77840f2..0000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -themeid=org.eclipse.e4.ui.css.theme.e4_dark diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.workbench.renderers.swt.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.workbench.renderers.swt.prefs deleted file mode 100644 index f19f0b9..0000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.workbench.renderers.swt.prefs +++ /dev/null @@ -1,6 +0,0 @@ -HIDE_ICONS_FOR_VIEW_TABS=false -SHOW_FULL_TEXT_FOR_VIEW_TABS=false -USE_ROUND_TABS=false -eclipse.preferences.version=1 -enableMRU=true -themeEnabled=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs index 8df2034..228ca18 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs @@ -1,3 +1,3 @@ -GitRepositoriesView.GitDirectories=/home/jacob/School/CS3/.git\: +GitRepositoriesView.GitDirectories=/home/jacob/CS3/.git\: GitRepositoriesView.GitDirectories.relative=.git\: eclipse.preferences.version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.mpc.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.mpc.ui.prefs deleted file mode 100644 index 0d8d62a..0000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.mpc.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -CatalogDescriptor=https\://marketplace.eclipse.org -eclipse.preferences.version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs index 950eba6..f395b7d 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs @@ -1,416 +1,6 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter= -org.eclipse.jdt.core.codeComplete.argumentPrefixes= -org.eclipse.jdt.core.codeComplete.argumentSuffixes= -org.eclipse.jdt.core.codeComplete.fieldPrefixes= -org.eclipse.jdt.core.codeComplete.fieldSuffixes= -org.eclipse.jdt.core.codeComplete.localPrefixes= -org.eclipse.jdt.core.codeComplete.localSuffixes= -org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= -org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 org.eclipse.jdt.core.compiler.compliance=21 org.eclipse.jdt.core.compiler.release=enabled org.eclipse.jdt.core.compiler.source=21 -org.eclipse.jdt.core.formatter.align_arrows_in_switch_on_columns=false -org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false -org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 -org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line=true -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false -org.eclipse.jdt.core.formatter.align_with_spaces=false -org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package=49 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter=0 -org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type=49 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assertion_message=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow=16 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon=16 -org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 -org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16 -org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_record_components=16 -org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0 -org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0 -org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow=20 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_type_annotations=0 -org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 -org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 -org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case_after_arrow=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_record_constructor=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_record_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true -org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false -org.eclipse.jdt.core.formatter.comment.indent_root_tags=false -org.eclipse.jdt.core.formatter.comment.indent_tag_description=false -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert -org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags=false -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true -org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true -org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=4 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=4 -org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=4 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert -org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert -org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert -org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.join_line_comments=false -org.eclipse.jdt.core.formatter.join_lines_in_comments=true -org.eclipse.jdt.core.formatter.join_wrapped_lines=true -org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=false -org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false -org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never -org.eclipse.jdt.core.formatter.lineSplit=120 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines -org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.text_block_indentation=0 -org.eclipse.jdt.core.formatter.use_on_off_tags=true -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true -org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true -org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator=true -org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false -org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true -org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true -org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true -org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true -org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true -org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true -org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true -org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true -org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator=false -org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs index 9dc2629..80dfde6 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs @@ -1,2 +1,2 @@ eclipse.preferences.version=1 -org.eclipse.jdt.launching.PREF_VM_XML=\n\n \n \n \n\n +org.eclipse.jdt.launching.PREF_VM_XML=\n\n \n \n \n\n diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs index 2850ad6..83c69da 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -1,6 +1,8 @@ content_assist_disabled_computers=org.eclipse.jdt.ui.textProposalCategory\u0000org.eclipse.jdt.ui.javaPostfixProposalCategory\u0000org.eclipse.jdt.ui.javaAllProposalCategory\u0000org.eclipse.jdt.ui.javaTypeProposalCategory\u0000org.eclipse.jdt.ui.javaNoTypeProposalCategory\u0000org.eclipse.jdt.ui.javaChainProposalCategory\u0000 content_assist_lru_history= content_assist_number_of_computers=15 +content_assist_proposals_background=255,255,255 +content_assist_proposals_foreground=0,0,0 eclipse.preferences.version=1 formatter_profile=_cs3 formatter_settings_version=23 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs deleted file mode 100644 index 67b1d96..0000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.m2e.discovery.pref.projects= diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs deleted file mode 100644 index 2a6fe50..0000000 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.java.ui.run.count.3_10_0=1 -org.eclipse.mylyn.java.ui.run.count.3_1_0=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs index 2b60c21..5330e43 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -2,4 +2,3 @@ eclipse.preferences.version=1 migrated.task.repositories.secure.store=true org.eclipse.mylyn.tasks.ui.filters.nonmatching=true org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true -org.eclipse.mylyn.tasks.ui.welcome.message=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs index b82d6f9..c0e492e 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -platformState=912090020149304 +platformState=898993722738329 quickStart=false tipsAndTricks=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs index 62252c0..08076f2 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs @@ -1,3 +1,2 @@ -CURRENT_THEME_ID=org.eclipse.ui.ide.systemDefault eclipse.preferences.version=1 showIntro=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs index 60f9b3a..adb28a9 100644 --- a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -1,5 +1,6 @@ //org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery; +RUN_IN_BACKGROUND=true eclipse.preferences.version=1 org.eclipse.compare.contentmergeviewer.TextMergeViewer=1|Monospace|10.0|0|GTK|1|; org.eclipse.debug.ui.DetailPaneFont=1|Monospace|10.0|0|GTK|1|; diff --git a/.metadata/.plugins/org.eclipse.debug.core/.launches/cs3.launch b/.metadata/.plugins/org.eclipse.debug.core/.launches/cs3.launch deleted file mode 100644 index 9a011e2..0000000 --- a/.metadata/.plugins/org.eclipse.debug.core/.launches/cs3.launch +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml deleted file mode 100644 index 936604f..0000000 --- a/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml +++ /dev/null @@ -1,23 +0,0 @@ - -
-
- - - - - - -
-
- - - - - -
-
- - - -
-
diff --git a/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml deleted file mode 100644 index 54ce69d..0000000 --- a/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi index 8b30c2f..eacd4b9 100644 --- a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -1,8 +1,8 @@ - + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration - + @@ -89,7 +89,7 @@ - + @@ -99,7 +99,8 @@ - + active + View categoryTag:General @@ -231,14 +232,11 @@ EditorStack org.eclipse.e4.primaryDataStack - active - + Editor removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor - active - activeOnClose @@ -246,6 +244,12 @@ removeOnHide org.eclipse.jdt.ui.CompilationUnitEditor + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + @@ -254,6 +258,8 @@ View categoryTag:Java + active + activeOnClose ViewMenu menuContribution:menu @@ -441,7 +447,7 @@ Draggable - + toolbarSeparator @@ -449,8 +455,8 @@ Draggable - - + + toolbarSeparator @@ -474,7 +480,10 @@ Draggable - + + + + Draggable toolbarSeparator @@ -2469,7 +2478,7 @@ - + diff --git a/.metadata/.plugins/org.eclipse.epp.mpc.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.epp.mpc.ui/dialog_settings.xml deleted file mode 100644 index 3a7caf3..0000000 --- a/.metadata/.plugins/org.eclipse.epp.mpc.ui/dialog_settings.xml +++ /dev/null @@ -1,10 +0,0 @@ - -
-
- - - - - -
-
diff --git a/.metadata/.plugins/org.eclipse.equinox.p2.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.equinox.p2.ui/dialog_settings.xml deleted file mode 100644 index 5ca0b77..0000000 --- a/.metadata/.plugins/org.eclipse.equinox.p2.ui/dialog_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - -
-
diff --git a/.metadata/.plugins/org.eclipse.jdt.core/1012296427.index b/.metadata/.plugins/org.eclipse.jdt.core/1012296427.index index 6b6500c..9f4b29a 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/1012296427.index and b/.metadata/.plugins/org.eclipse.jdt.core/1012296427.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index index 5aad012..2025c57 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index and b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/2954488155.index b/.metadata/.plugins/org.eclipse.jdt.core/2954488155.index deleted file mode 100644 index 1b993a5..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/2954488155.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index b/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index index becc5f6..aac8986 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index and b/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/365334263.index b/.metadata/.plugins/org.eclipse.jdt.core/365334263.index index 708611a..7ca0fdf 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/365334263.index and b/.metadata/.plugins/org.eclipse.jdt.core/365334263.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/3659629937.index b/.metadata/.plugins/org.eclipse.jdt.core/3659629937.index index 07ce4f2..b12f723 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/3659629937.index and b/.metadata/.plugins/org.eclipse.jdt.core/3659629937.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/783481251.index b/.metadata/.plugins/org.eclipse.jdt.core/783481251.index deleted file mode 100644 index 8132168..0000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/783481251.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/972395290.index b/.metadata/.plugins/org.eclipse.jdt.core/972395290.index index 64dbdc5..626a2e6 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/972395290.index and b/.metadata/.plugins/org.eclipse.jdt.core/972395290.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache index 593f470..ef308e1 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache and b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache index 6c79ce8..8ea00b6 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache and b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps b/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps index 04f4de1..84960ba 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps and b/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache index ef308e1..10a60f5 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache and b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt index 7672e5b..1e198cc 100644 --- a/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt +++ b/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt @@ -1,11 +1,9 @@ -INDEX VERSION 1.134+/home/jacob/School/CS3/.metadata/.plugins/org.eclipse.jdt.core -1012296427.index -3443351165.index -365334263.index -972395290.index -783481251.index -3408771930.index -3659629937.index -1865797976.index +INDEX VERSION 1.134+/home/jacob/CS3/.metadata/.plugins/org.eclipse.jdt.core 3487212494.index -2954488155.index +3443351165.index +1865797976.index +3659629937.index +3024544230.index +972395290.index +1012296427.index +365334263.index diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat index 684e6d1..bc24c79 100644 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat and b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/.metadata/.plugins/org.eclipse.jdt.debug.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.debug.ui/dialog_settings.xml deleted file mode 100644 index 6b6e6fe..0000000 --- a/.metadata/.plugins/org.eclipse.jdt.debug.ui/dialog_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
-
diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml index 7ca0a2e..9e390f5 100644 --- a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -1,15 +1,2 @@ - - - - - - - - - - - - - - + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml index 5a6f47c..020f890 100644 --- a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -1,6 +1,6 @@
- + diff --git a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/accumulators/2024/11/45/refactorings.history b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/accumulators/2024/11/45/refactorings.history deleted file mode 100644 index a733cba..0000000 --- a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/accumulators/2024/11/45/refactorings.history +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/accumulators/2024/11/45/refactorings.index b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/accumulators/2024/11/45/refactorings.index deleted file mode 100644 index ce73591..0000000 --- a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/accumulators/2024/11/45/refactorings.index +++ /dev/null @@ -1 +0,0 @@ -1730841194994 Delete element diff --git a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/trees/2024/11/45/refactorings.history b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/trees/2024/11/45/refactorings.history deleted file mode 100644 index 3e6cd59..0000000 --- a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/trees/2024/11/45/refactorings.history +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/trees/2024/11/45/refactorings.index b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/trees/2024/11/45/refactorings.index deleted file mode 100644 index feac46b..0000000 --- a/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/trees/2024/11/45/refactorings.index +++ /dev/null @@ -1 +0,0 @@ -1730842077401 Delete element diff --git a/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml deleted file mode 100644 index dcde5d4..0000000 --- a/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/.executables/data.properties b/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/.executables/data.properties deleted file mode 100644 index 1ded6a5..0000000 --- a/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/.executables/data.properties +++ /dev/null @@ -1 +0,0 @@ -#Mon Nov 04 21:04:58 EST 2024 diff --git a/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/dialog_settings.xml deleted file mode 100644 index 77b6c9b..0000000 --- a/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/dialog_settings.xml +++ /dev/null @@ -1,11 +0,0 @@ - -
-
- -
-
- -
-
-
-
diff --git a/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml deleted file mode 100644 index 50f1edb..0000000 --- a/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
-
diff --git a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml index 5cbd3b4..50881cd 100644 --- a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml +++ b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -1,18 +1,22 @@
-
- - - - - - +
+ + + + + + + -
+ + + +
- - + +
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml deleted file mode 100644 index 93673b8..0000000 --- a/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml +++ /dev/null @@ -1,12 +0,0 @@ - -
- - - - - - - - - -
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml index 9f83a73..4335373 100644 --- a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -1,10 +1,18 @@
- - - - + + + +
+
+ + + + +
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml index 3863590..9e6d3ce 100644 --- a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +++ b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/.metadata/version.ini b/.metadata/version.ini index 0468577..ad34afa 100644 --- a/.metadata/version.ini +++ b/.metadata/version.ini @@ -1,3 +1,3 @@ -#Tue Nov 19 11:31:34 EST 2024 +#Thu Nov 21 00:03:57 EST 2024 org.eclipse.core.runtime=2 org.eclipse.platform=4.33.0.v20240903-0240 diff --git a/abstraction/.classpath b/abstraction/.classpath index f9ed317..91fefed 100644 --- a/abstraction/.classpath +++ b/abstraction/.classpath @@ -6,7 +6,7 @@ - - + + diff --git a/accumulators/.classpath b/accumulators/.classpath index f9ed317..91fefed 100644 --- a/accumulators/.classpath +++ b/accumulators/.classpath @@ -6,7 +6,7 @@ - - + + diff --git a/delegation/.classpath b/delegation/.classpath index f9ed317..91fefed 100644 --- a/delegation/.classpath +++ b/delegation/.classpath @@ -6,7 +6,7 @@ - - + + diff --git a/fibonacci/.classpath b/fibonacci/.classpath index f9ed317..91fefed 100644 --- a/fibonacci/.classpath +++ b/fibonacci/.classpath @@ -6,7 +6,7 @@ - - + + diff --git a/generics/.classpath b/generics/.classpath index f9ed317..91fefed 100644 --- a/generics/.classpath +++ b/generics/.classpath @@ -6,7 +6,7 @@ - - + + diff --git a/mastermind/.classpath b/mastermind/.classpath index f9ed317..91fefed 100644 --- a/mastermind/.classpath +++ b/mastermind/.classpath @@ -6,7 +6,7 @@ - - + + diff --git a/trees/.classpath b/trees/.classpath index f9ed317..91fefed 100644 --- a/trees/.classpath +++ b/trees/.classpath @@ -6,7 +6,7 @@ - - + +