marking4/output
author Christian Urban <urbanc@in.tum.de>
Wed, 30 Oct 2019 14:07:58 +0000
changeset 288 65731df141a5
parent 257 ba4d976ca88d
child 300 72688efdf17c
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
257
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
Below is the feedback and provisional marks for your submission
288
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
     3
for the core part of assignment 9.  Please note all marks are provisional until
257
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
ratified by the assessment board -- this is not an official
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
results transcript.
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
288
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
     7
re.scala does not contain vars, returns, Arrays, ListBuffers etc?
257
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
  --> success
288
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
     9
re.scala runs?
257
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
  --> success
288
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    11
 nullable(ZERO) == false
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    12
 nullable(ONE) == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    13
 nullable(CHAR('a')) == false
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    14
 nullable(ZERO | ONE) == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    15
 nullable(ZERO | CHAR('a')) == false
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    16
 nullable(ONE ~  ONE) == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    17
 nullable(ONE ~ CHAR('a')) == false
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    18
 nullable(STAR(ZERO)) == true
257
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
  --> success
288
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    20
 der('a', ZERO | ONE) == (ZERO | ZERO)
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    21
 der('a', (CHAR('a') | ONE) ~ CHAR('a')) == ALT((ONE | ZERO) ~ CHAR('a'), ONE)
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    22
 der('a', (CHAR('a') | CHAR('a')) ~ CHAR('a')) == (ONE | ONE) ~ CHAR('a')
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    23
 der('a', STAR(CHAR('a'))) == (ONE ~ STAR(CHAR('a')))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    24
 der('b', STAR(CHAR('a'))) == (ZERO ~ STAR(CHAR('a')))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    25
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    26
 val r0 = "a" ~ "b" ~ "c"
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    27
 assert(der('a', r0) == (ONE ~ "b") ~ "c")
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    28
 assert(der('b', r0) == (ZERO ~ "b") ~ "c")
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    29
 assert(der('c', r0) == (ZERO ~ "b") ~ "c")
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    30
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    31
 val r1 = (ONE ~ "b") ~ "c"
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    32
 assert(der('a', r1) == ((ZERO ~ "b") | ZERO) ~ "c")
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    33
 assert(der('b', r1) == ((ZERO ~ "b") | ONE) ~ "c")
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    34
 assert(der('c', r1) == ((ZERO ~ "b") | ZERO) ~ "c")
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    35
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    36
 val r2 = ((ZERO ~ "b") | ONE) ~ "c"
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    37
 assert(der('a', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    38
 assert(der('b', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ZERO))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    39
 assert(der('c', r2) == ((((ZERO ~ "b") | ZERO) ~ "c") | ONE))
257
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  --> success
288
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    41
 simp(ZERO | ONE) == ONE
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    42
 simp(STAR(ZERO | ONE)) == STAR(ZERO | ONE)
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    43
 simp(ONE ~ (ONE ~ (ONE ~ CHAR('a')))) == CHAR('a')
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    44
 simp(((ONE ~ ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    45
 simp(((ONE | ONE) ~ ONE) ~ CHAR('a')) == CHAR('a')
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    46
 simp(ONE ~ (ONE ~ (ONE ~ ZERO))) == ZERO
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    47
 simp(ALT(ONE ~ (ONE ~ (ONE ~ ZERO)), CHAR('a'))) == CHAR('a')
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    48
 simp(CHAR('a') | CHAR('a')) == CHAR('a')
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    49
 simp(CHAR('a') ~ CHAR('a')) == CHAR('a') ~ CHAR('a')
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    50
 simp(ONE | CHAR('a')) == (ONE | CHAR('a'))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    51
 simp(ALT((CHAR('a') | ZERO) ~ ONE,
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    52
          ((ONE | CHAR('b')) | CHAR('c')) ~ (CHAR('d') ~ ZERO))) == CHAR('a')
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    53
 simp((ZERO | ((ZERO | ZERO) | (ZERO | ZERO))) ~ ((ONE | ZERO) | ONE ) ~ (CHAR('a'))) == ZERO
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    54
 simp(ALT(ONE | ONE, ONE | ONE)) == ONE
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    55
 simp(ALT(ZERO | CHAR('a'), CHAR('a') | ZERO)) == CHAR('a')
257
ba4d976ca88d updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
  --> success
288
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    57
 val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    58
 ders(("a" * 5).toList,EVIL) == SEQ(SEQ(STAR(CHAR('a')),STAR(STAR(CHAR('a')))),CHAR('b'))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    59
 ders(List('b'),EVIL) == ONE
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    60
 ders(List('b','b'),EVIL) == ZERO
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    61
 matcher(EVIL, "a" * 5 ++ "b") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    62
 matcher(EVIL, "a" * 50 ++ "b") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    63
 matcher(EVIL, "a" * 50) == false
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    64
 matcher(EVIL, "b") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    65
 matcher(EVIL, "bb") == false
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    66
 matcher("abc", "abc") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    67
 matcher("abc", "ab") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    68
 matcher(("ab" | "a") ~ (ONE | "bc"), "abc") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    69
 matcher(ONE, "") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    70
 matcher(ZERO, "") == false
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    71
 matcher(ONE | CHAR('a'), "") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    72
 matcher(ONE | CHAR('a'), "a") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    73
  --> success
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    74
 val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    75
 size(der('a', der('a', EVIL))) == 28
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    76
 size(der('a', der('a', der('a', EVIL)))) == 58
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    77
 size(ders("aaaaaa".toList, EVIL)) == 8
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    78
 size(ders(("a" * 50).toList, EVIL)) == 8
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    79
  --> success
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    80
 simp(Iterator.iterate(ONE:Rexp)(r => SEQ(r, ONE | ONE)).drop(50).next) == ONE
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    81
    ...the Iterator produces the rexp
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    82
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    83
      SEQ(SEQ(SEQ(..., ONE | ONE) , ONE | ONE), ONE | ONE)
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    84
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    85
    where SEQ is nested 50 times.
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    86
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    87
 simp(Iterator.iterate(ONE:Rexp)(r => ALT(r, r)).drop(20).next) == ONE
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    88
    ... the Iterator produces a rexp of size 2097151
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    89
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    90
 val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b'))
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    91
 matcher(EVIL, "a" * 1000000 ++ "b") == true
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    92
 matcher(EVIL, "a" * 1000000) == false
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    93
  --> success
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    94
Overall mark for CW 9, Core Part
65731df141a5 updated
Christian Urban <urbanc@in.tum.de>
parents: 257
diff changeset
    95
6