def distance_threshold(threshold):
    """
    A higher order function that returns a predicate which
    is only true if the distance is less than threshold.
    """
    def predicate(distance):
        if distance<=threshold:
            return True
        else:
            return False
    return predicate