marking4/postfix_test10.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Sun, 09 Jan 2022 01:06:30 +0000
changeset 420 4edc1a308652
parent 329 8a34b2ebc8cc
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
329
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
import CW9b._
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
assert(compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
assert(compute(syard(split("10 + 12 * 33"))) == 406)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
assert(compute(syard(split("( 5 + 7 ) * 2"))) == 24)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
assert(compute(syard(split("5 + 7 / 2"))) == 8)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
assert(compute(syard(split("5 * 7 / 2"))) == 17)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
assert(compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
assert(compute(syard(split("4 ^ 3 ^ 2"))) == 262144)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
assert(compute(syard(split("4 ^ ( 3 ^ 2 )"))) == 262144)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
assert(compute(syard(split("( 4 ^ 3 ) ^ 2"))) == 4096)
8a34b2ebc8cc updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
assert(compute(syard(split("( 3 + 1 ) ^ 2 ^ 3"))) == 65536)