diff -r c493eaba6018 -r 65731df141a5 templates4/postfix2.scala --- a/templates4/postfix2.scala Wed Oct 30 12:47:10 2019 +0000 +++ b/templates4/postfix2.scala Wed Oct 30 14:07:58 2019 +0000 @@ -2,6 +2,9 @@ // including Associativity for Operators // ===================================== +object CW9b { + + // type of tokens type Toks = List[String] @@ -32,7 +35,7 @@ // the operations in the basic version of the algorithm val ops = List("+", "-", "*", "/", "^") -// (8) Implement the extended version of the shunting yard algorithm. +// (3) Implement the extended version of the shunting yard algorithm. // This version should properly account for the fact that the power // operation is right-associative. Apart from the extension to include // the power operation, you can make the same assumptions as in @@ -45,7 +48,7 @@ // syard(split("3 + 4 * 8 / ( 5 - 1 ) ^ 2 ^ 3")) // 3 4 8 * 5 1 - 2 3 ^ ^ / + -// (9) Implement a compute function that produces a Long(!) for an +// (4) Implement a compute function that produces a Long(!) for an // input list of tokens in postfix notation. //def compute(toks: Toks, st: List[Long] = Nil) : Long = ... @@ -63,3 +66,4 @@ // compute(syard(split("( 4 ^ 3 ) ^ 2"))) // 4096 // compute(syard(split("( 3 + 1 ) ^ 2 ^ 3"))) // 65536 +}