Functional programming exercise using recursion to check for balanced parenthesis