1 |
1 |
2 Below is the feedback and provisional marks for your submission |
2 Below is the feedback and provisional marks for your submission |
3 for assignment 9 Part 2. Please note all marks are provisional until |
3 for the core part of assignment 9. Please note all marks are provisional until |
4 ratified by the assessment board -- this is not an official |
4 ratified by the assessment board -- this is not an official |
5 results transcript. |
5 results transcript. |
6 |
6 |
7 postfix.scala does not contain vars, returns, Arrays, ListBuffers etc? |
7 re.scala does not contain vars, returns, Arrays, ListBuffers etc? |
8 --> success |
8 --> success |
9 postfix.scala runs? |
9 re.scala runs? |
10 --> success |
10 --> success |
11 syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "\*", "+") |
11 nullable(ZERO) == false |
12 syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+") |
12 nullable(ONE) == true |
13 syard(split("5 + 7 / 2")) == List("5", "7", "2", "/", "+") |
13 nullable(CHAR('a')) == false |
14 syard(split("5 * 7 / 2")) == List("5", "7", "\*", "2", "/") |
14 nullable(ZERO | ONE) == true |
|
15 nullable(ZERO | CHAR('a')) == false |
|
16 nullable(ONE ~ ONE) == true |
|
17 nullable(ONE ~ CHAR('a')) == false |
|
18 nullable(STAR(ZERO)) == true |
15 --> success |
19 --> success |
16 compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7 |
20 der('a', ZERO | ONE) == (ZERO | ZERO) |
17 compute(syard(split("10 + 12 * 33"))) == 406 |
21 der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE) |
18 compute(syard(split("( 5 + 7 ) * 2"))) == 24 |
22 der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a') |
19 compute(syard(split("5 + 7 / 2"))) == 8 |
23 der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a'))) |
20 compute(syard(split("5 * 7 / 2"))) == 17 |
24 der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a'))) |
21 compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15 |
25 |
|
26 val r0 = "a" ~ "b" ~ "c" |
|
27 assert(der('a', r0) == (ONE ~ "b") ~ "c") |
|
28 assert(der('b', r0) == (ZERO ~ "b") ~ "c") |
|
29 assert(der('c', r0) == (ZERO ~ "b") ~ "c") |
|
30 |
|
31 val r1 = (ONE ~ "b") ~ "c" |
|
32 assert(der('a', r1) == ((ZERO ~ "b") | ZERO) ~ "c") |
|
33 assert(der('b', r1) == ((ZERO ~ "b") | ONE) ~ "c") |
|
34 assert(der('c', r1) == ((ZERO ~ "b") | ZERO) ~ "c") |
|
35 |
|
36 val r2 = ((ZERO ~ "b") | ONE) ~ "c" |
|
37 assert(der('a', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO)) |
|
38 assert(der('b', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO)) |
|
39 assert(der('c', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ONE)) |
22 --> success |
40 --> success |
23 postfix2.scala does not contain vars, returns, Arrays, ListBuffers etc? |
41 simp(ZERO | ONE) == ONE |
|
42 simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE) |
|
43 simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a') |
|
44 simp(((ONE ~ ONE) ~ ONE) ~ CHAR('a')) == CHAR('a') |
|
45 simp(((ONE | ONE) ~ ONE) ~ CHAR('a')) == CHAR('a') |
|
46 simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO |
|
47 simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a') |
|
48 simp(CHAR('a') | CHAR('a')) == CHAR('a') |
|
49 simp(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a') |
|
50 simp(ONE | CHAR('a')) == (ONE | CHAR('a')) |
|
51 simp(ALT((CHAR('a') | ZERO) ~ ONE, |
|
52 ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a') |
|
53 simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO |
|
54 simp(ALT(ONE | ONE, ONE | ONE)) == ONE |
|
55 simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a') |
24 --> success |
56 --> success |
25 postfix2.scala runs? |
57 val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) |
|
58 ders(("a" * 5).toList,EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b')) |
|
59 ders(List('b'),EVIL) == ONE |
|
60 ders(List('b','b'),EVIL) == ZERO |
|
61 matcher(EVIL, "a" * 5 ++ "b") == true |
|
62 matcher(EVIL, "a" * 50 ++ "b") == true |
|
63 matcher(EVIL, "a" * 50) == false |
|
64 matcher(EVIL, "b") == true |
|
65 matcher(EVIL, "bb") == false |
|
66 matcher("abc", "abc") == true |
|
67 matcher("abc", "ab") == true |
|
68 matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true |
|
69 matcher(ONE, "") == true |
|
70 matcher(ZERO, "") == false |
|
71 matcher(ONE | CHAR('a'), "") == true |
|
72 matcher(ONE | CHAR('a'), "a") == true |
26 --> success |
73 --> success |
27 syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "\*", "+") |
74 val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) |
28 syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+") |
75 size(der('a', der('a', EVIL))) == 28 |
29 syard(split("5 + 7 / 2")) == List("5", "7", "2", "/", "+") |
76 size(der('a', der('a', der('a', EVIL)))) == 58 |
30 syard(split("5 * 7 / 2")) == List("5", "7", "\*", "2", "/") |
77 size(ders("aaaaaa".toList, EVIL)) == 8 |
31 syard(split("3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3")) == |
78 size(ders(("a" * 50).toList, EVIL)) == 8 |
32 List("3", "4", "8", "\*", "5", "1", "-", "2", "3", "^", "^", "/", "+") |
|
33 |
|
34 compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7 |
|
35 compute(syard(split("10 + 12 * 33"))) == 406 |
|
36 compute(syard(split("( 5 + 7 ) * 2"))) == 24 |
|
37 compute(syard(split("5 + 7 / 2"))) == 8 |
|
38 compute(syard(split("5 * 7 / 2"))) == 17 |
|
39 compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15 |
|
40 compute(syard(split("4 ^ 3 ^ 2"))) == 262144 |
|
41 compute(syard(split("4 ^ ( 3 ^ 2 )"))) == 262144 |
|
42 compute(syard(split("( 4 ^ 3 ) ^ 2"))) == 4096 |
|
43 compute(syard(split("( 3 + 1 ) ^ 2 ^ 3"))) == 65536 |
|
44 --> success |
79 --> success |
45 Overall mark for CW 9, Part 2 |
80 simp(Iterator.iterate(ONE:Rexp)(r => SEQ(r, ONE | ONE)).drop(50).next) == ONE |
46 4 |
81 ...the Iterator produces the rexp |
|
82 |
|
83 SEQ(SEQ(SEQ(..., ONE | ONE) , ONE | ONE), ONE | ONE) |
|
84 |
|
85 where SEQ is nested 50 times. |
|
86 |
|
87 simp(Iterator.iterate(ONE:Rexp)(r => ALT(r, r)).drop(20).next) == ONE |
|
88 ... the Iterator produces a rexp of size 2097151 |
|
89 |
|
90 val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) |
|
91 matcher(EVIL, "a" * 1000000 ++ "b") == true |
|
92 matcher(EVIL, "a" * 1000000) == false |
|
93 --> success |
|
94 Overall mark for CW 9, Core Part |
|
95 6 |