import functools


def unif_segmented(x, segments):
    """Define indicative function of union of intevals in [0, 1].

    Parameters
    ----------
    x : float in [0, 1]
        function variable
    segments : list of intervals in [0, 1]
        ex: [[0.1, 0.2], [0.5, 1.]]

    Returns
    -------
    0 or 1 : value of function on x

    """
    in_seg = [seg[0] <= x <= seg[1] for seg in segments]
    return functools.reduce( (lambda x, y: x or y), in_seg )