pre_testing3/postfix_test9.scala
author Christian Urban <christian.urban@kcl.ac.uk>
Tue, 24 Nov 2020 09:04:06 +0000
changeset 366 1c829680503e
parent 346 663c2a9108d1
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
346
663c2a9108d1 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents: 300
diff changeset
     1
import CW8b._
300
72688efdf17c updated testing files
Christian Urban <urbanc@in.tum.de>
parents: 249
diff changeset
     2
249
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
assert(syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "*", "+"))
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
assert(syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+"))
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
assert(syard(split("5 + 7 / 2")) == List("5", "7", "2", "/", "+"))
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
assert(syard(split("5 * 7 / 2")) == List("5", "7", "*", "2", "/"))
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
assert(syard(split("3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3")) == List("3", "4", "8", "*", "5", "1", "-", "2", "3", "^", "^", "/", "+"))
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
assert(compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
assert(compute(syard(split("10 + 12 * 33"))) == 406)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
assert(compute(syard(split("( 5 + 7 ) * 2"))) == 24)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
assert(compute(syard(split("5 + 7 / 2"))) == 8)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
assert(compute(syard(split("5 * 7 / 2"))) == 17)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
assert(compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
assert(compute(syard(split("4 ^ 3 ^ 2"))) == 262144)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
assert(compute(syard(split("4 ^ ( 3 ^ 2 )"))) == 262144)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
assert(compute(syard(split("( 4 ^ 3 ) ^ 2"))) == 4096)
1997cfcd6334 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
assert(compute(syard(split("( 3 + 1 ) ^ 2 ^ 3"))) == 65536)