is_in_domain: check whether a value is in a domain
Description
A convenience function to see if a value is inside
(or on the boundaries of) a domain or a set of domain segments.
In the case of multiple segments, the check is
whether val is within any of them.