How to use the funcy.funcmakers.make_func function in funcy

To help you get started, we’ve selected a few funcy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Suor / funcy / funcy / funcs.py View on Github external
def compose(*fs):
    """Composes passed functions."""
    if fs:
        pair = lambda f, g: lambda *a, **kw: f(g(*a, **kw))
        return reduce(pair, map(make_func, fs))
    else:
        return identity
github Suor / funcy / funcy / seqs.py View on Github external
def map(f, *seqs):
    """An extended version of builtin imap().
       Derives a mapper from string, int, slice, dict or set."""
    return _map(make_func(f, builtin=PY2), *seqs)
github Suor / funcy / funcy / seqs.py View on Github external
def group_by(f, seq):
    """Groups given sequence items into a mapping f(item) -> [item, ...]."""
    f = make_func(f)
    result = defaultdict(list)
    for item in seq:
        result[f(item)].append(item)
    return result
github Suor / funcy / funcy / seqs.py View on Github external
def partition_by(f, seq):
    """Lazily partition seq into continuous chunks with constant value of f."""
    f = make_func(f)
    for _, items in groupby(seq, f):
        yield items
github Suor / funcy / funcy / colls.py View on Github external
def walk_keys(f, coll):
    """Walks keys of the collection, mapping them with f."""
    f = make_func(f)
    # NOTE: we use this awkward construct instead of lambda to be Python 3 compatible
    def pair_f(pair):
        k, v = pair
        return f(k), v

    return walk(pair_f, coll)
github Suor / funcy / funcy / funcs.py View on Github external
def iffy(pred, action=EMPTY, default=identity):
    """Creates a function, which conditionally applies action or default."""
    if action is EMPTY:
        return iffy(bool, pred, default)
    else:
        pred = make_pred(pred)
        action = make_func(action)
        return lambda v: action(v)  if pred(v) else           \
                         default(v) if callable(default) else \
                         default
github Suor / funcy / funcy / seqs.py View on Github external
def xmap(f, *seqs):
        return _map(make_func(f), *seqs)
else: