示例#1
0
def mapwith(function):
    """
    >>> sum(map(int, '1 2 7 2'.split()))
    12
    >>> toints = mapwith(int)
    >>> sum(toints('1 2 7 2'.split()))
    12
    >>> '1 2 7 2'.split() |mapwith(int) |postfix(sum)
    12
    """
    return postfix(lambda *iterables: map(function, *iterables))
示例#2
0
def formatwith(fmt):
    return postfix(partial(
        format, format_spec=fmt))  # postfix(lambda x:format(x, fmt))
示例#3
0
def lfilterwith(function):
    """ @see filterwith """
    return postfix(lambda *iterables: lfilter(function, *iterables))
示例#4
0
def lmapwith(function):
    """ @see mapwith """
    return postfix(lambda *iterables: lmap(function, *iterables))
示例#5
0
def filterwith(function):
    return postfix(lambda *iterables: filter(function, *iterables))