title: Scala - pattern head/tail on Map
body: <p>I'm trying to make a tail recursive method but i'm using Map and i don't know how to use Pattern Matching to check if Map is empty/null and get head/tail:</p>
  
  <pre><code>def aa(a:Map[String, Seq[Operation]]): Map[String, (Seq[Operation], Double)] = {
  
      def aaRec(xx:Map[String, Seq[Operation]],
                res:Map[String, (Seq[Operation], Double)],
                acc:Double = 0): Map[String, (Seq[Operation], Double)] = xx match {
        case ? =&gt; 
          res
        case _ =&gt; 
          val head = xx.head
          val balance = head._2.foldLeft(acc)(_ + _.amount)
          aaRec(xx.tail, res + (head._1 -&gt; (head._2, balance)), balance)
      }
  
      aaRec(a, Map[String, (Seq[Operation], Double)]())
  
      }
  }
  </code></pre>
  
  <p>What is the correct syntax on case empty map and case h :: t?</p>
  
  <p>Thank's in advance</p>