You must write a program or function that takes a string of brackets and outputs whether or not that string is fully matched. Your program should print a truthy or falsy value, and IO can be in any reasonable format.
Rules and definitions:
For the purpose of this challenge, a "bracket" is any of these characters:
()[]{}<>
.A pair of brackets is considered "matched" if the opening and closing brackets are in the right order and have no characters inside of them, such as
() []{}
Or if every subelement inside of it is also matched.
[()()()()] {<[]>} (()())
Subelements can also be nested several layers deep.
[(){<><>[()]}<>()] <[{((()))}]>
A string is considered "Fully matched" if and only if:
Every single character is a bracket,
Each pair of brackets has the correct opening and closing bracket and in the right order, and
Each bracket is matched.
You may assume the input will only contain printable ASCII.
Test IO
Here are some inputs that should return a truthy value:
()
[](){}<>
(((())))
({[<>]})
[{()<>()}[]]
[([]{})<{[()<()>]}()>{}]
And here are some outputs that should return a falsy value:
( Has no closing ')'
}{ Wrong order
(<)> Each pair contains only half of a matched element
(()()foobar) Contains invalid characters
[({}<>)> The last bracket should be ']' instead of '>'
(((())) Has 4 opening brackets, but only 3 closing brackets.
As usual, this is code-golf, so standard loopholes apply, and shortest answer in bytes wins.
[}
a match? And if not, where is it excluded by these rules? \$\endgroup\$Each pair of brackets has the correct opening and closing bracket and in the right order.
\$\endgroup\$