def p_any(*predicates): """Return a lambda that evaluates to True if ANY the predicates passed are truthy. The predicates can be functions or values. :param predicates: a list of callables or values :returns: Callable(fn: -> boolean) :raises: may raise anything, depending on the callables """ return Callable(lambda: any((_resolve_callable(p) for p in predicates)))
def p_not(predicate): """Return a lambda that does the NOT of the predicate passed The predicate can be a value or a function :param predicate: a value or function (FN() -> ?) :returns: Callable(fn: -> boolean) :raises: may raise anything, depending on the callables """ return Callable(lambda: not _resolve_callable(predicate))
def __le__(self, other): return Callable(lambda: not self.__gt__(other)())
def __gt__(self, other): assert isinstance(other, str) or isinstance(other, self.__class__) if other not in self._list: raise KeyError("Item '{}' is not in list '{}'".format( other, self._list)) return Callable(lambda: self.index > self._list.index(other))
def __ne__(self, other): return Callable(lambda: not self.__eq__(other)())
def __gt__(self, other): return Callable( lambda: _resolve_callable(self.item) > _resolve_callable(other))