feat: move everything to single folder

This commit is contained in:
Yadunand Prem
2022-11-05 10:28:46 +08:00
parent 0eb6cd0b30
commit 44c87f3500
315 changed files with 48612 additions and 0 deletions

50
cs2030s/Lab7/Test2.java Normal file
View File

@@ -0,0 +1,50 @@
import cs2030s.fp.Combiner;
import cs2030s.fp.Memo;
public class Test2 {
public static void main(String[] args) {
CS2030STest we = new CS2030STest();
int[] eval = new int[]{0};
Combiner<Integer, Integer, Integer> fib = (x, y) -> {
eval[0] += 1;
return x + y;
};
MemoList<Integer> l = MemoList.generate(8, 0, 1, fib);
we.expect(
"An initial MemoList only has the first two values evaluated",
l.toString(),
"[0, 1, ?, ?, ?, ?, ?, ?]"
);
l.indexOf(5);
we.expect(
"Looking for 5 causes 4 evaluations",
eval[0],
4
);
l.indexOf(3);
we.expect(
"Looking for 3 does not need any more evaluation",
eval[0],
4
);
l.get(4);
we.expect(
"Retrieving index 4 does not need any more evaluation",
eval[0],
4
);
l.get(6);
we.expect(
"Retrieving 6 causes one more evaluation",
eval[0],
5
);
}
}