def to_predicate(x):
    """
    Turn `x` into a predicate.
    
    If `x` is callable, it will be called with a single argument and returned value determines if the argument passes.
    If `x` is a container, an argument passes if it's contained in `x`.
    """
    if hasattr(x,"__call__"):
        return x
    if hasattr(x,"__contains__"):
        return lambda e: e in x
    raise ValueError("can't build predicate for {0}".format(x))