marking4/postfix.scala
changeset 288 3cd6c850c252
parent 257 71e534e28430
equal deleted inserted replaced
287:a0c469a58ed4 288:3cd6c850c252
     1 // Shunting Yard Algorithm
     1 // Shunting Yard Algorithm
     2 // by Edsger Dijkstra
     2 // by Edsger Dijkstra
     3 // ========================
     3 // ========================
     4 
     4 
     5 //object CW9b {
     5 object CW9a {
     6 
     6 
     7 type Toks = List[String]
     7 type Toks = List[String]
     8 
     8 
     9 // the operations in the simple version
     9 // the operations in the simple version
    10 val ops = List("+", "-", "*", "/")
    10 val ops = List("+", "-", "*", "/")
    96 // compute(syard(split("( 5 + 7 ) * 2")))      // 24
    96 // compute(syard(split("( 5 + 7 ) * 2")))      // 24
    97 // compute(syard(split("5 + 7 / 2")))          // 8
    97 // compute(syard(split("5 + 7 / 2")))          // 8
    98 // compute(syard(split("5 * 7 / 2")))          // 17
    98 // compute(syard(split("5 * 7 / 2")))          // 17
    99 // compute(syard(split("9 + 24 / ( 7 - 3 )"))) // 15
    99 // compute(syard(split("9 + 24 / ( 7 - 3 )"))) // 15
   100 
   100 
   101 //}
   101 }
   102 
   102 
   103 
   103