A solution for the classic parentheses counting problem solved in a tail-recursive way using Scala.