@@ -649,7 +649,7 @@ they can be used to define the type of the trees for our example:
649649``` scala 
650650abstract  class  Tree 
651651object  Tree  {
652-   case  class  Sum (l : Tree , r : Tree ) extends  Tree 
652+   case  class  Sum (left : Tree , right : Tree ) extends  Tree 
653653  case  class  Var (n : String ) extends  Tree 
654654  case  class  Const (v : Int ) extends  Tree 
655655}
@@ -682,7 +682,7 @@ but also to implement ADTs. Here is how they can be used to define the type
682682of the trees for our example:
683683``` scala 
684684enum  Tree : 
685-   case  Sum (l : Tree , r : Tree )
685+   case  Sum (left : Tree , right : Tree )
686686  case  Var (n : String )
687687  case  Const (v : Int )
688688``` 
@@ -750,7 +750,7 @@ Scala as follows, using a pattern match on a tree value `t`:
750750import  Tree ._ 
751751
752752def  eval (t : Tree , ev : Environment ):  Int  =  t match  {
753-   case  Sum (l, r ) =>  eval(l , ev) +  eval(r , ev)
753+   case  Sum (left, right ) =>  eval(left , ev) +  eval(right , ev)
754754  case  Var (n)    =>  ev(n)
755755  case  Const (v)  =>  v
756756}
@@ -762,7 +762,7 @@ def eval(t: Tree, ev: Environment): Int = t match {
762762import  Tree .* 
763763
764764def  eval (t : Tree , ev : Environment ):  Int  =  t match 
765-   case  Sum (l, r ) =>  eval(l , ev) +  eval(r , ev)
765+   case  Sum (left, right ) =>  eval(left , ev) +  eval(right , ev)
766766  case  Var (n)    =>  ev(n)
767767  case  Const (v)  =>  v
768768``` 
@@ -773,12 +773,12 @@ def eval(t: Tree, ev: Environment): Int = t match
773773You can understand the precise meaning of the pattern match as follows:
774774
7757751 .  it first checks if the tree ` t `  is a ` Sum ` , and if it
776-    is, it binds the left sub-tree to a new variable called ` l `  and
777-    the right sub-tree to a variable called ` r ` , and then proceeds
776+    is, it binds the left sub-tree to a new variable called ` left `  and
777+    the right sub-tree to a variable called ` right ` , and then proceeds
778778   with the evaluation of the expression following the arrow; this
779779   expression can (and does) make use of the variables bound by the
780-    pattern appearing on the left of the arrow, i.e., ` l `  and
781-    ` r ` ,
780+    pattern appearing on the left of the arrow, i.e., ` left `  and
781+    ` right ` ,
7827822 .  if the first check does not succeed, that is, if the tree is not
783783   a ` Sum ` , it goes on and checks if ` t `  is a ` Var ` ; if
784784   it is, it binds the name contained in the ` Var `  node to a
@@ -841,7 +841,7 @@ obtain the following definition:
841841import  Tree ._ 
842842
843843def  derive (t : Tree , v : String ):  Tree  =  t match  {
844-   case  Sum (l, r )        =>  Sum (derive(l , v), derive(r , v))
844+   case  Sum (left, right )        =>  Sum (derive(left , v), derive(right , v))
845845  case  Var (n) if  v ==  n =>  Const (1 )
846846  case  _                =>  Const (0 )
847847}
@@ -853,7 +853,7 @@ def derive(t: Tree, v: String): Tree = t match {
853853import  Tree .* 
854854
855855def  derive (t : Tree , v : String ):  Tree  =  t match 
856-   case  Sum (l, r )        =>  Sum (derive(l , v), derive(r , v))
856+   case  Sum (left, right )        =>  Sum (derive(left , v), derive(right , v))
857857  case  Var (n) if  v ==  n =>  Const (1 )
858858  case  _                =>  Const (0 )
859859``` 
0 commit comments