pre_testing3/postfix_test9.scala
changeset 401 9471c3b7ea02
parent 400 e48ea8300b2d
child 402 de59aa20a1dc
equal deleted inserted replaced
400:e48ea8300b2d 401:9471c3b7ea02
     1 import CW8b._
       
     2 
       
     3 
       
     4 assert(syard(split("3 + 4 * ( 2 - 1 )")) == List("3", "4", "2", "1", "-", "*", "+"))
       
     5 assert(syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) == List("3", "4", "5", "+", "+"))
       
     6 assert(syard(split("5 + 7 / 2")) == List("5", "7", "2", "/", "+"))
       
     7 assert(syard(split("5 * 7 / 2")) == List("5", "7", "*", "2", "/"))
       
     8 assert(syard(split("3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3")) == List("3", "4", "8", "*", "5", "1", "-", "2", "3", "^", "^", "/", "+"))
       
     9 
       
    10 
       
    11 
       
    12 assert(compute(syard(split("3 + 4 * ( 2 - 1 )"))) == 7)
       
    13 assert(compute(syard(split("10 + 12 * 33"))) == 406)
       
    14 assert(compute(syard(split("( 5 + 7 ) * 2"))) == 24)
       
    15 assert(compute(syard(split("5 + 7 / 2"))) == 8)
       
    16 assert(compute(syard(split("5 * 7 / 2"))) == 17)
       
    17 assert(compute(syard(split("9 + 24 / ( 7 - 3 )"))) == 15)
       
    18 assert(compute(syard(split("4 ^ 3 ^ 2"))) == 262144)
       
    19 assert(compute(syard(split("4 ^ ( 3 ^ 2 )"))) == 262144)
       
    20 assert(compute(syard(split("( 4 ^ 3 ) ^ 2"))) == 4096)
       
    21 assert(compute(syard(split("( 3 + 1 ) ^ 2 ^ 3"))) == 65536)