title: Functional programming, Scala map and fold left
body: <p>What are some good tutorials on fold left?</p>
  
  <p><em>Original question, restored from deletion to provide context for other answers:</em></p>
  
  <p>I am trying to implement a method for finding the boudning box of rectangle, circle, location and the group which all extends Shape. Group is basically an array of Shapes</p>
  
  <pre><code>abstract class Shape  
  case class Rectangle(width: Int, height: Int) extends Shape  
  case class Location(x: Int, y: Int, shape: Shape) extends Shape  
  case class Circle(radius: Int) extends Shape  
  case class Group(shape: Shape*) extends Shape  
  </code></pre>
  
  <p>I got the bounding box computed for all three except the Group one. So now for the bounding box method I know I should be using map and fold left for Group, but I just can't find out the exact syntax of creating it.</p>
  
  <pre><code>object BoundingBox {  
    def boundingBox(s: Shape): Location = s match {  
      case Circle(c)=&gt;   
        new Location(-c,-c,s)  
      case Rectangle(_, _) =&gt;  
        new Location(0, 0, s)  
      case Location(x, y, shape) =&gt; {  
        val b = boundingBox(shape)  
        Location(x + b.x, y + b.y, b.shape)  
      }  
      case Group(shapes @ _*) =&gt;  ( /: shapes) { } // i dont know how to proceed here.
    }
  }
  </code></pre>
  
  <p>Group bounding box is basically the smallest bounding box with all the shapes enclosed.</p>