Tagged as challenge
Written on 2018-02-06
We all know the problem of checking/counting parentheses pairs. This time, given a list of open and close characters which must match each other, check if the expression is valid. For example, consider the following pairs:
(defparameter *open-close-pairs*
'((#\( . #\))
(#\[ . #\])
(#\{ . #\})
(#\< . #\>)))
Write a function validate
which takes a string like "({<>[()]}[])"
and a table of open-close pairs and return a Boolean indicating the
validity of the string.