Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.35 KB | None | 0 0
  1. /**
  2.    * Exercise 2
  3.    */
  4.     def balance(chars: List[Char]): Boolean = {
  5.       def innerBalance(chars: List[Char], counter: Int) : Boolean = {
  6.         if (counter < 0) false
  7.         else if (chars.isEmpty) counter == 0
  8.         else {
  9.           innerBalance(chars.tail, counter + smth(chars.head))
  10.         }
  11.       }
  12.       innerBalance(chars, 0)
  13.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement