templates4/postfix.scala
changeset 288 65731df141a5
parent 220 3020f8c76baa
--- a/templates4/postfix.scala	Wed Oct 30 12:47:10 2019 +0000
+++ b/templates4/postfix.scala	Wed Oct 30 14:07:58 2019 +0000
@@ -2,6 +2,7 @@
 // by Edsger Dijkstra
 // ========================
 
+object CW9a {
 
 // type of tokens
 type Toks = List[String]
@@ -19,7 +20,7 @@
 def split(s: String) : Toks = s.split(" ").toList
 
 
-// (6) Implement below the shunting yard algorithm. The most
+// (1) Implement below the shunting yard algorithm. The most
 // convenient way to this in Scala is to implement a recursive 
 // function and to heavily use pattern matching. The function syard 
 // takes some input tokens as first argument. The second and third 
@@ -56,7 +57,7 @@
 //syard(split("( ( ( 3 ) ) + ( ( 4 + ( 5 ) ) ) )")) // 3 4 5 + +
 
  
-// (7) Implement a compute function that evaluates an input list
+// (2) Implement a compute function that evaluates an input list
 // in postfix notation. This function takes a list of tokens
 // and a stack as argumenta. The function should produce the 
 // result as an integer using the stack. You can assume 
@@ -74,6 +75,6 @@
 // compute(syard(split("5 * 7 / 2")))          // 17
 // compute(syard(split("9 + 24 / ( 7 - 3 )"))) // 15
 
+}
 
 
-