import typing


def clamp(
    value: typing.Union[int, float] = 0.5,
    minimum: typing.Union[int, float] = 0,
    maximum: typing.Union[int, float] = 1
) -> typing.Union[int, float]:
    """
    Returns the clamped value between *minimum* and *maximum*

    A clamped value is the value itself when it lies
    between the minimum and the maximum, and if the
    value crosses the extremes, then the extremity
    closer to the value becomes the clamped value.
    
    E.g.:
    clamp() -> clamp(0.5, 0, 1) -> 0.5;
    clamp(2, 0, 1) -> 1;
    clamp(-1, 0, 1) -> 0;
    """

    if value < minimum:
        return minimum
    
    if value > maximum:
        return maximum
    
    return value