diff --git a/.gitignore b/.gitignore index 14bd998..17932c3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,5 @@ hs_err_pid* replay_pid* **/bin/ -.metadata/ .old/ +.metadata/ diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.mylyn/.taskListIndex/segments_1 b/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 0000000..0dff951 Binary files /dev/null and b/.metadata/.mylyn/.taskListIndex/segments_1 differ diff --git a/.metadata/.mylyn/.taskListIndex/write.lock b/.metadata/.mylyn/.taskListIndex/write.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/14/705e7113c9a1001f17dbd629bd636125 b/.metadata/.plugins/org.eclipse.core.resources/.history/14/705e7113c9a1001f17dbd629bd636125 new file mode 100644 index 0000000..47a8b45 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/14/705e7113c9a1001f17dbd629bd636125 @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..5bc3d20 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/16/70edcae5d5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..7f3ccdf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1a/d0738772d8a2001f13baf1c76b2fe20e @@ -0,0 +1,162 @@ +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 new file mode 100644 index 0000000..5e76658 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/b05f9b03d6a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..21aa1f9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1d/60a430cfd5a2001f13baf1c76b2fe20e @@ -0,0 +1,146 @@ +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 new file mode 100644 index 0000000..cc4eaa5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2/b00c6400c9a1001f17dbd629bd636125 @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..2212654 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/25/a084793ad9a2001f13baf1c76b2fe20e @@ -0,0 +1,180 @@ +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 new file mode 100644 index 0000000..c44b925 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/27/30da8faad6a2001f13baf1c76b2fe20e @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..c44b925 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2d/d09e4d00d7a2001f13baf1c76b2fe20e @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..eb1b26c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2e/f02da9a8d8a2001f13baf1c76b2fe20e @@ -0,0 +1,163 @@ +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 new file mode 100644 index 0000000..92a1a7a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/70c4a71cc9a1001f17dbd629bd636125 @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..bb0686a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/2f/f0c6b88ed6a2001f13baf1c76b2fe20e @@ -0,0 +1,149 @@ +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 new file mode 100644 index 0000000..c222a70 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/00b7d2dcd7a2001f13baf1c76b2fe20e @@ -0,0 +1,155 @@ +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 new file mode 100644 index 0000000..6ddb399 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3e/b04c2e2a95a6001f1f99f28bbdc62909 @@ -0,0 +1,131 @@ +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 new file mode 100644 index 0000000..5a7ffb5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3f/70dc808fd7a2001f13baf1c76b2fe20e @@ -0,0 +1,153 @@ +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 new file mode 100644 index 0000000..af2c99c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4/c08ee01ad6a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/47/e0575f8ad6a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/47/e0575f8ad6a2001f13baf1c76b2fe20e new file mode 100644 index 0000000..93b34b3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/47/e0575f8ad6a2001f13baf1c76b2fe20e @@ -0,0 +1,149 @@ +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 new file mode 100644 index 0000000..e7edeb8 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/48/4080d6bbd7a2001f13baf1c76b2fe20e @@ -0,0 +1,155 @@ +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 new file mode 100644 index 0000000..7775a01 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/48/d0153d80d7a2001f13baf1c76b2fe20e @@ -0,0 +1,153 @@ +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 new file mode 100644 index 0000000..8c2a64f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4c/b083956fcaa1001f17dbd629bd636125 @@ -0,0 +1,94 @@ +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 new file mode 100644 index 0000000..c44b925 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/4d/c086d608d7a2001f13baf1c76b2fe20e @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..6b087b4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/53/60620459caa1001f17dbd629bd636125 @@ -0,0 +1,94 @@ +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 new file mode 100644 index 0000000..f48fe61 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/55/10eba5b6d7a2001f13baf1c76b2fe20e @@ -0,0 +1,154 @@ +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 new file mode 100644 index 0000000..010ab46 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/56/70843000d8a2001f13baf1c76b2fe20e @@ -0,0 +1,155 @@ +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 new file mode 100644 index 0000000..ae60648 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/57/907a27f7d8a2001f13baf1c76b2fe20e @@ -0,0 +1,176 @@ +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 new file mode 100644 index 0000000..e3e6a74 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/58/b07536a6d7a2001f13baf1c76b2fe20e @@ -0,0 +1,153 @@ +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 new file mode 100644 index 0000000..e806c30 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5b/201de412caa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..2c8f0b9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5b/408f217bd7a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..fe0b3c1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5c/c0854747d8a2001f13baf1c76b2fe20e @@ -0,0 +1,155 @@ +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 new file mode 100644 index 0000000..c44b925 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/5f/203aabc1d6a2001f13baf1c76b2fe20e @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..1947461 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/63/00e57d53caa1001f17dbd629bd636125 @@ -0,0 +1,94 @@ +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 new file mode 100644 index 0000000..cc4eaa5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6a/70991c5b19a1001f1cb38ee0d7d0c4d1 @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..2e91149 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6b/0061f8dfd7a2001f13baf1c76b2fe20e @@ -0,0 +1,155 @@ +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 new file mode 100644 index 0000000..c655732 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6b/0095a8d8c9a1001f17dbd629bd636125 @@ -0,0 +1,89 @@ +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 new file mode 100644 index 0000000..0f58d86 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/70/208ee9e4d5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..03b8bb3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/73/6069c0c4d6a2001f13baf1c76b2fe20e @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..ff0b2e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/77/50668705d8a2001f13baf1c76b2fe20e @@ -0,0 +1,156 @@ +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 new file mode 100644 index 0000000..7531b56 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8/50c70724caa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..b965bf5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/84/306cebfed5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..c44b925 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/86/30b04fa1d6a2001f13baf1c76b2fe20e @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..8d52982 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/20257291d7a2001f13baf1c76b2fe20e @@ -0,0 +1,153 @@ +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 new file mode 100644 index 0000000..9146a52 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8a/d0c286a6caa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..7d4adb5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8c/40db7a00d5a2001f13baf1c76b2fe20e @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..e806c30 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9/70802834caa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..e8cfb67 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/94/00d63222d7a2001f13baf1c76b2fe20e @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..b0fe763 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/9c/b01fe771d9a2001f13baf1c76b2fe20e @@ -0,0 +1,180 @@ +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 new file mode 100644 index 0000000..5bc3d20 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a0/1081b6d0d5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..55e2b60 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a4/60092434d7a2001f13baf1c76b2fe20e @@ -0,0 +1,153 @@ +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 new file mode 100644 index 0000000..2c94e56 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a5/009f4a1ec9a1001f17dbd629bd636125 @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000..7ee7362 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/a7/103b2322d6a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..8d414ed --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/aa/20b1a633d9a2001f13baf1c76b2fe20e @@ -0,0 +1,178 @@ +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 new file mode 100644 index 0000000..59115f4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ae/30548af095a6001f1f99f28bbdc62909 @@ -0,0 +1,832 @@ +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 new file mode 100644 index 0000000..cc4eaa5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/8099c438caa5001f1d5fac7c5024adb1 @@ -0,0 +1,7 @@ +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 new file mode 100644 index 0000000..e0bcc78 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b0/b07254e5c9a1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..a4b8402 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b1/20e416e9d5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..be87018 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b1/6045e1f2d8a2001f13baf1c76b2fe20e @@ -0,0 +1,174 @@ +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 new file mode 100644 index 0000000..7a9e0d9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b1/90319d7cbda2001f15f3ea04fc682a70 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..7864742 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/509e7e76caa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..5bc3d20 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b5/d0dd3cd3d5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..704e17f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b7/00975a60d8a2001f13baf1c76b2fe20e @@ -0,0 +1,160 @@ +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 new file mode 100644 index 0000000..5aab356 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b8/606810c5c9a1001f17dbd629bd636125 @@ -0,0 +1,82 @@ +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 new file mode 100644 index 0000000..f330e18 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/3035bce4d8a2001f13baf1c76b2fe20e @@ -0,0 +1,166 @@ +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 new file mode 100644 index 0000000..6481e47 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bc/b0f4c33ecaa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..5bc3d20 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c5/007f5fdad5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/b0dff607d8a2001f13baf1c76b2fe20e b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/b0dff607d8a2001f13baf1c76b2fe20e new file mode 100644 index 0000000..6cad6e1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/b0dff607d8a2001f13baf1c76b2fe20e @@ -0,0 +1,156 @@ +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 new file mode 100644 index 0000000..2df2340 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/db/c051ac7fcaa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..1a5d152 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/df/20e4d12e95a6001f1f99f28bbdc62909 @@ -0,0 +1,130 @@ +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 new file mode 100644 index 0000000..bec6d90 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/df/d0a5984dcaa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..4196669 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e/c0b41b9bd6a2001f13baf1c76b2fe20e @@ -0,0 +1,149 @@ +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 new file mode 100644 index 0000000..db70c78 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e1/a0052e21d6a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..242814e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e4/f0f0a1ead5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..94eb4f0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e6/00802f0bd9a2001f13baf1c76b2fe20e @@ -0,0 +1,176 @@ +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 new file mode 100644 index 0000000..5606413 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e7/40be406dcaa1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..d94e2b2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ea/f0427239caa1001f17dbd629bd636125 @@ -0,0 +1,94 @@ +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 new file mode 100644 index 0000000..0309341 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/eb/70b55cebd5a2001f13baf1c76b2fe20e @@ -0,0 +1,147 @@ +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 new file mode 100644 index 0000000..fc96fc3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ee/20654556caa5001f1d5fac7c5024adb1 @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..5346f57 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f3/a09bc128d7a2001f13baf1c76b2fe20e @@ -0,0 +1,153 @@ +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 new file mode 100644 index 0000000..2cdffca --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f5/c04072dfc9a1001f17dbd629bd636125 @@ -0,0 +1,93 @@ +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 new file mode 100644 index 0000000..e8cfb67 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f9/f0558abfd6a2001f13baf1c76b2fe20e @@ -0,0 +1,151 @@ +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 new file mode 100644 index 0000000..5eade1a Binary files /dev/null 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 new file mode 100644 index 0000000..6baa17a Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/af/history.index 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 new file mode 100644 index 0000000..d5d1699 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/e4/5a/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/.indexes/properties.index 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 new file mode 100644 index 0000000..727cb73 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/abstraction/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Wed Nov 13 09:09:56 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 new file mode 100644 index 0000000..92d1657 Binary files /dev/null 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/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/.indexes/properties.index 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 new file mode 100644 index 0000000..aef0f88 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/accumulators/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Nov 05 15:25:59 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 new file mode 100644 index 0000000..757bc2d Binary files /dev/null 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 new file mode 100644 index 0000000..5a9e1a7 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/af/history.index 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 new file mode 100644 index 0000000..1503766 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/e4/da/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/.indexes/properties.index 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 new file mode 100644 index 0000000..75ea3ea --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/fibonacci/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Mon Nov 18 11:29:02 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 new file mode 100644 index 0000000..2c3e2b9 Binary files /dev/null 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 new file mode 100644 index 0000000..a8c0f93 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/af/history.index 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 new file mode 100644 index 0000000..1f630b2 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/e4/7c/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/.indexes/properties.index 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 new file mode 100644 index 0000000..b94d40b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/generics/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Nov 12 12:12:54 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 new file mode 100644 index 0000000..d2399c5 Binary files /dev/null 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 new file mode 100644 index 0000000..419d37c Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/e4/4c/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.location b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.location new file mode 100644 index 0000000..761f0a0 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.location differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers new file mode 100644 index 0000000..772679a Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers 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 new file mode 100644 index 0000000..96fd897 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Mon Nov 04 20:43:42 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 new file mode 100644 index 0000000..ce2ffff Binary files /dev/null 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/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/.indexes/properties.index 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 new file mode 100644 index 0000000..f2a0665 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/trees/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Nov 05 16:24:07 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 new file mode 100644 index 0000000..02994e5 Binary files /dev/null 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/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 0000000..25cb955 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000..9d5973b Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/17.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/17.tree new file mode 100644 index 0000000..bd3fa66 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/17.tree 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 new file mode 100644 index 0000000..9650df2 Binary files /dev/null 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 new file mode 100644 index 0000000..139c2a4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.vrapper.eclipse.prefs @@ -0,0 +1,2 @@ +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 new file mode 100644 index 0000000..565f933 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ant.ui.prefs @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000..30841eb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding=UTF-8 +version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs new file mode 100644 index 0000000..fa9476c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\n\n +preferredDetailPanes=DefaultDetailPane,org.eclipse.jdt.debug.ui.JAVA_VARIABLE_DETAIL_PANE_VARIABLES\:org.eclipse.jdt.debug.ui.JAVA_VARIABLE_DETAIL_PANE_VARIABLES|DefaultDetailPane\:DefaultDetailPane| +preferredTargets=default\:default| 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 new file mode 100644 index 0000000..77840f2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs @@ -0,0 +1,2 @@ +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 new file mode 100644 index 0000000..f19f0b9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.workbench.renderers.swt.prefs @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..8df2034 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs @@ -0,0 +1,3 @@ +GitRepositoriesView.GitDirectories=/home/jacob/School/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 new file mode 100644 index 0000000..0d8d62a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.epp.mpc.ui.prefs @@ -0,0 +1,2 @@ +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 new file mode 100644 index 0000000..950eba6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,416 @@ +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.junit.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs new file mode 100644 index 0000000..31df02c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.junit.content_assist_favorite_static_members_migrated=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 new file mode 100644 index 0000000..9dc2629 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +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 new file mode 100644 index 0000000..2850ad6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,15 @@ +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 +eclipse.preferences.version=1 +formatter_profile=_cs3 +formatter_settings_version=23 +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.formatterprofiles=\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n +org.eclipse.jdt.ui.formatterprofiles.version=23 +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.overrideannotation=true +spelling_locale_initialized=true +typefilter_migrated_2=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true 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 new file mode 100644 index 0000000..67b1d96 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.discovery.pref.projects= diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs new file mode 100644 index 0000000..43e97e4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +mylyn.attention.migrated=true 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 new file mode 100644 index 0000000..2a6fe50 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs @@ -0,0 +1,3 @@ +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.monitor.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs new file mode 100644 index 0000000..8d462a6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true 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 new file mode 100644 index 0000000..2b60c21 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..b82d6f9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +platformState=912090020149304 +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 new file mode 100644 index 0000000..62252c0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000..60f9b3a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -0,0 +1,81 @@ +//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; +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|; +org.eclipse.debug.ui.MemoryViewTableFont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.debug.ui.consoleFont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.egit.ui.CommitMessageEditorFont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.egit.ui.CommitMessageFont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.egit.ui.DiffHeadlineFont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.jdt.internal.ui.compare.JavaMergeViewer=1|Monospace|10.0|0|GTK|1|; +org.eclipse.jdt.internal.ui.compare.PropertiesFileMergeViewer=1|Monospace|10.0|0|GTK|1|; +org.eclipse.jdt.ui.PropertiesFileEditor.textfont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.jdt.ui.editors.textfont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.jface.textfont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.mylyn.wikitext.ui.presentation.textFont=1|Monospace|10.0|0|GTK|1|; +org.eclipse.ui.ide.systemDefault.CONFLICTING_COLOR=240,15,66 +org.eclipse.ui.ide.systemDefault.CONTENT_ASSIST_BACKGROUND_COLOR=52,57,61 +org.eclipse.ui.ide.systemDefault.CONTENT_ASSIST_FOREGROUND_COLOR=238,238,238 +org.eclipse.ui.ide.systemDefault.EDITION_COLOR=238,238,238 +org.eclipse.ui.ide.systemDefault.INCOMING_COLOR=31,179,235 +org.eclipse.ui.ide.systemDefault.OUTGOING_COLOR=238,238,238 +org.eclipse.ui.ide.systemDefault.RESOLVED_COLOR=108,210,17 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.CommitMessageCommentColor=128,128,128 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffAddBackgroundColor=11,121,90 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffAddForegroundColor=216,254,245 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffHeadlineBackgroundColor=71,71,71 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffHeadlineForegroundColor=242,242,242 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffHunkBackgroundColor=53,97,113 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffHunkForegroundColor=233,242,254 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffRemoveBackgroundColor=117,2,36 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffRemoveForegroundColor=255,232,237 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.IgnoredResourceBackgroundColor=47,47,47 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.IgnoredResourceForegroundColor=120,120,120 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.UncommittedChangeBackgroundColor=47,47,47 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.UncommittedChangeForegroundColor=114,157,186 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.ColoredLabels.inherited=143,143,191 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.ColoredLabels.match_highlight=206,92,0 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.ColoredLabels.writeaccess_highlight=255,128,128 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.Javadoc.backgroundColor=52,57,61 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.Javadoc.foregroundColor=238,238,238 +org.eclipse.ui.ide.systemDefault.org.eclipse.jface.REVISION_NEWEST_COLOR=75,44,3 +org.eclipse.ui.ide.systemDefault.org.eclipse.jface.REVISION_OLDEST_COLOR=154,113,61 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.color.text.quoted=106,133,255 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.category.gradient.end=136,137,133 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.category.gradient.start=85,87,83 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.foreground.past.scheduled=52,101,164 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.foreground.task.active=117,80,123 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.foreground.thisweek.scheduled=85,87,83 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.foreground.today.scheduled=52,101,164 +org.eclipse.ui.ide.systemDefault.org.eclipse.search.ui.match.highlight=206,92,0 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.editors.rangeIndicatorColor=27,118,153 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END=41,41,41 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=43,44,45 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_TEXT_COLOR=204,204,204 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_BG_END=41,41,41 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_BG_START=43,44,45 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_INNER_KEYLINE_COLOR=75,76,79 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_OUTER_KEYLINE_COLOR=75,76,79 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_OUTLINE_COLOR=75,76,79 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR=221,221,221 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_UNSELECTED_TABS_COLOR_END=64,64,67 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_UNSELECTED_TABS_COLOR_START=73,74,77 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_BG_END=49,53,56 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_BG_START=59,64,66 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_INNER_KEYLINE_COLOR=81,86,88 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_OUTER_KEYLINE_COLOR=81,86,88 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_OUTLINE_COLOR=59,64,66 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_TEXT_COLOR=187,187,187 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_UNSELECTED_TABS_COLOR_END=70,70,73 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_UNSELECTED_TABS_COLOR_START=81,86,88 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INFORMATION_BACKGROUND=81,86,88 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INFORMATION_FOREGROUND=238,238,238 +org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END=255,255,255 +org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=255,255,255 +org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_TEXT_COLOR=16,16,16 +org.eclipse.ui.workbench.ACTIVE_TAB_BG_END=255,255,255 +org.eclipse.ui.workbench.ACTIVE_TAB_BG_START=255,255,255 +org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR=46,52,54 +org.eclipse.ui.workbench.INACTIVE_TAB_BG_START=246,245,244 +terminal.views.view.font.definition=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 new file mode 100644 index 0000000..9a011e2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.debug.core/.launches/cs3.launch @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml new file mode 100644 index 0000000..936604f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml @@ -0,0 +1,23 @@ + +
+
+ + + + + + +
+
+ + + + + +
+
+ + + +
+
diff --git a/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml new file mode 100644 index 0000000..54ce69d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 0000000..8b30c2f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2513 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + + + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewRecordCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.newWizSC:org.eclipse.m2e.core.wizards.Maven2ProjectWizard + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.viewSC:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.viewSC:org.eclipse.jdt.bcoview.views.BytecodeOutlineView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + persp.actionSet:org.eclipse.debug.ui.debugActionSet + persp.editorOnboardingImageUri:platform:/plugin/org.eclipse.jdt.ui/$nl$/icons/full/onboarding_jperspective.png + persp.editorOnboardingText:Open a file or drop files here to open them. + persp.editorOnboardingCommand:Find Actions$$$Ctrl+3 + persp.editorOnboardingCommand:Show Key Assist$$$Shift+Ctrl+L + persp.editorOnboardingCommand:New$$$Ctrl+N + persp.editorOnboardingCommand:Open Type$$$Shift+Ctrl+T + + + + View + categoryTag:Git + + + + + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Ant + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + + + + org.eclipse.e4.secondaryDataStack + Java + Debug + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Terminal + + + View + categoryTag:Java + + + View + categoryTag:Debug + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + EditorStack + org.eclipse.e4.primaryDataStack + active + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + active + activeOnClose + + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + + + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Git + + + + + + View + categoryTag:Terminal + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + + View + categoryTag:Debug + + ViewMenu + menuContribution:menu + + + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + TrimStack + Draggable + + + + + TrimStack + Draggable + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + platform:gtk + + + + + + platform:gtk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:gtk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:Help + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Language Servers + + + + + View + categoryTag:Language Servers + + + + + View + categoryTag:Language Servers + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:General + + + + + View + categoryTag:Version Control (Team) + + + + + View + categoryTag:Version Control (Team) + + + View + categoryTag:Help + + + + + View + categoryTag:Terminal + + + + + View + categoryTag:Other + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.project b/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.project new file mode 100644 index 0000000..3c10856 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.project @@ -0,0 +1,11 @@ + + + .org.eclipse.egit.core.cmp + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.settings/org.eclipse.core.resources.prefs b/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.metadata/.plugins/org.eclipse.epp.mpc.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.epp.mpc.ui/dialog_settings.xml new file mode 100644 index 0000000..3a7caf3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.epp.mpc.ui/dialog_settings.xml @@ -0,0 +1,10 @@ + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.equinox.p2.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.equinox.p2.ui/dialog_settings.xml new file mode 100644 index 0000000..5ca0b77 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.equinox.p2.ui/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/.metadata/.plugins/org.eclipse.jdt.core/1012296427.index b/.metadata/.plugins/org.eclipse.jdt.core/1012296427.index new file mode 100644 index 0000000..6b6500c Binary files /dev/null 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 new file mode 100644 index 0000000..5aad012 Binary files /dev/null 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 new file mode 100644 index 0000000..1b993a5 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/2954488155.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/3408771930.index b/.metadata/.plugins/org.eclipse.jdt.core/3408771930.index new file mode 100644 index 0000000..d1bb350 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/3408771930.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/3443351165.index b/.metadata/.plugins/org.eclipse.jdt.core/3443351165.index new file mode 100644 index 0000000..a415b83 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/3443351165.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index b/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index new file mode 100644 index 0000000..becc5f6 Binary files /dev/null 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 new file mode 100644 index 0000000..708611a Binary files /dev/null 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 new file mode 100644 index 0000000..07ce4f2 Binary files /dev/null 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 new file mode 100644 index 0000000..8132168 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/783481251.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/972395290.index b/.metadata/.plugins/org.eclipse.jdt.core/972395290.index new file mode 100644 index 0000000..64dbdc5 Binary files /dev/null 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 new file mode 100644 index 0000000..593f470 Binary files /dev/null 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 new file mode 100644 index 0000000..6c79ce8 Binary files /dev/null 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 new file mode 100644 index 0000000..04f4de1 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt new file mode 100644 index 0000000..8586397 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000..ef308e1 Binary files /dev/null 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 new file mode 100644 index 0000000..7672e5b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt @@ -0,0 +1,11 @@ +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 +3487212494.index +2954488155.index diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000..684e6d1 Binary files /dev/null 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 new file mode 100644 index 0000000..6b6e6fe --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.debug.ui/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml b/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml new file mode 100644 index 0000000..59948c0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml b/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml new file mode 100644 index 0000000..6dfd7e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 0000000..a4ee3cb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 0000000..7ca0a2e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 0000000..5a6f47c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,56 @@ + +
+ + + + + + + + + + + + + + + + +
+ + + + + +
+
+
+
+
+
+
+
+ +
+
+ + + + + +
+
+ + + + + +
+
+ +
+
+ + +
+
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 new file mode 100644 index 0000000..a733cba --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/accumulators/2024/11/45/refactorings.history @@ -0,0 +1,4 @@ + + + + \ 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 new file mode 100644 index 0000000..ce73591 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/accumulators/2024/11/45/refactorings.index @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000..3e6cd59 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/trees/2024/11/45/refactorings.history @@ -0,0 +1,4 @@ + + + + \ 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 new file mode 100644 index 0000000..feac46b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.core.refactoring/.refactorings/trees/2024/11/45/refactorings.index @@ -0,0 +1 @@ +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 new file mode 100644 index 0000000..dcde5d4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml @@ -0,0 +1,7 @@ + +
+
+ + +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser new file mode 100644 index 0000000..abbf8e5 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser differ diff --git a/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.6.1.20240411-1122.xml b/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.6.1.20240411-1122.xml new file mode 100644 index 0000000..9effde7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.6.1.20240411-1122.xml @@ -0,0 +1,41 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + ${org.eclipse.m2e.log.console.threshold:-OFF} + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 10MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser b/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser new file mode 100644 index 0000000..1e9a069 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser differ diff --git a/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 0000000..1f73e14 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 0000000..5ca0b77 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
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 new file mode 100644 index 0000000..1ded6a5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/.executables/data.properties @@ -0,0 +1 @@ +#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 new file mode 100644 index 0000000..77b6c9b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/dialog_settings.xml @@ -0,0 +1,11 @@ + +
+
+ +
+
+ +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml new file mode 100644 index 0000000..50f1edb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 0000000..5cbd3b4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,19 @@ + +
+
+ + + + + + + +
+ + + + + +
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.intro/introstate b/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 0000000..02f134f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml new file mode 100644 index 0000000..93673b8 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml @@ -0,0 +1,12 @@ + +
+ + + + + + + + + +
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 0000000..9f83a73 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,10 @@ + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 0000000..3863590 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.metadata/version.ini b/.metadata/version.ini new file mode 100644 index 0000000..0468577 --- /dev/null +++ b/.metadata/version.ini @@ -0,0 +1,3 @@ +#Tue Nov 19 11:31:34 EST 2024 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.33.0.v20240903-0240