Simplify code

is_nesting_open returns a boolean with a equation value a true or false.
valid_close was using similar if statements I replaced all by a simple switch-case statement.
We can add parentheses if you prefer so, but professionally a programmer has to do the same kind of algorithms for a function returning a boolean.