Convert a curried function into a function on tuples
    (of positional arguments) and dictionaries (of keyword arguments).
327358
def uncurry(f):
    
    ensure_callable(f)

    result = lambda args=(), kwargs=None: f(*args, **(kwargs or {}))
    functools.update_wrapper(result, f, ('__name__', '__module__'))
    return result
845414
function substitution(f, g, x) {
  if(!(isFunction(f) && isFunction(g))) {
    throw new TypeError(
      'substitution: Functions required for first two arguments'
    )
  }

  return curry(f)(x, g(x))
}
350253
def func_reconstruct_closure(values):
    
    nums = range(len(values))
    src = ["def func(arg):"]
    src += ["  _%d = arg[%d]" % (n, n) for n in nums]
    src += ["  return lambda:(%s)" % ','.join(["_%d" % n for n in nums]), ""]
    src = '\n'.join(src)
    try:
        exec(src, globals())
    except:
        raise SyntaxError(src)
    return func(values).__closure__
1050792
def _(f, x):
    
    return {k: v for k, v in x.items() if f(k, v)}
360459
def _process_function(chaining, routine):
    

    def processing(*args, **kwargs):
        """Execute routine with input args and kwargs and add reuslt in
        chaining.___.

        :param tuple args: routine varargs.
        :param dict kwargs: routine kwargs.
        :return: chaining chaining.
        :rtype: Chaining
        """

        result = routine(*args, **kwargs)
        chaining.___.append(result)

        return chaining

    return processing
1012885
function composeK(...args) {
  if(!arguments.length) {
    throw new TypeError(err)
  }

  const fns =
    args.slice().reverse()

  const head =
    fns[0]

  if(!isFunction(head)) {
    throw new TypeError(err)
  }

  if(fns.length === 1) {
    return head
  }

  const tail = fns.slice(1).reduce((comp, fn) => {
    if(!isFunction(fn)) {
      throw new TypeError(err)
    }

    return function(m) {
      if(!isChain(m)) {
        throw new TypeError(err)
      }
      return comp(m).chain(fn)
    }
  }, x => x)

  return function() {
    return tail(head.apply(null, arguments))
  }
}
1361775
function _curry3 (fn) {
  return function f3 (a, b, c) {
    switch (arguments.length) {
      case 0:
        return f3
      case 1:
        return _curry2(function (_b, _c) {
          return fn(a, _b, _c)
        })
      case 2:
        return function (_c) {
          return fn(a, b, _c)
        }
      default:
        return fn(a, b, c)
    }
  }
}
1073824
function curry(fn, obj) {
  // create a local copy of the function. don't apply anything yet
  // optionally bind an object to the `this` of the function.
  var newFunction = _.bind(fn, (obj || null));

  // curried functions always take one argument
  return function () {
    // create another copy of the function with the arguments applied
    var me = _.partial(newFunction, arguments);

    // take advantage of the fact that bind changes the method signature:
    // if we have no arguments left, run the method
    if (!me.length) return me();

    // otherwise, curry again and return that.
    return curry(me);
  };
}
541977
def arg_to_array(func):
    
    def fn(self, arg, *args, **kwargs):
        """Function

        Parameters
        ----------
        arg : array-like
            Argument to convert.
        *args : tuple
            Arguments.
        **kwargs : dict
            Keyword arguments.

        Returns
        -------
        value : object
            The return value of the function.
        """
        return func(self, np.array(arg), *args, **kwargs)
    return fn
601723
def map_arg(**maps):
    
    def deco(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            if six.PY2:
                argmap = inspect.getcallargs(func, *args, **kwargs)
            else:
                # getcallargs was deprecated since 3.5
                sig = inspect.signature(func)
                argmap = sig.bind_partial(*args, **kwargs).arguments
            for k, map_func in six.iteritems(maps):
                if k in argmap:
                    argmap[k] = map_func(argmap[k])
            return func(**argmap)
        return wrapper
    return deco
595398
function _curriedr (f, xs) {
    let t = typeOf(f);
    if (t === 'Function') {
        return f.length <= 1 ? f : arity(f.length - xs.length, (...ys) => {
            let a = [...xs, ...ys].filter(v => v !== void 0);
            if (a.length >= f.length) { return f(...a.reverse()); }
            return _curriedr(f, a);
        });
    }
    throw `curryRight :: Expected argument to be of type function but saw ${t}`;
}
1248098
@Pure
	public static <P1, P2, P3, RESULT> Function2<P2, P3, RESULT> curry(final Function3<? super P1, ? super P2, ? super P3, ? extends RESULT> function,
			final P1 argument) {
		if (function == null)
			throw new NullPointerException("function");
		return new Function2<P2, P3, RESULT>() {
			@Override
			public RESULT apply(P2 p2, P3 p3) {
				return function.apply(argument, p2, p3);
			}
		};
	}
630296
def tuplify(*args):
    
    if (len(args) == 1) and callable(args[0]):
        func = args[0]

        @wraps(func)
        def _inner(*args, **kwargs):
            return tuple(func(*args, **kwargs))
        return _inner
    else:
        return tuple(args)
192264
def transform(transform_func):
    """"""
    def decorator(func):
        @wraps(func)
        def f(*args, **kwargs):
            return transform_func(
                func(*args, **kwargs)
            )
        return f
    return decorator
769012
function curry(fn) {
  return function(...xs) {
    const args =
      xs.length ? xs : [ undefined ]

    if(args.length < fn.length) {
      return curry(Function.bind.apply(fn, [ null ].concat(args)))
    }

    const val = args.length === fn.length
      ? fn.apply(null, args)
      : args.reduce(applyCurry, fn)

    if(isFunction(val)) {
      return curry(val)
    }

    return val
  }
}
132778
def map(self, func: Callable[[Tuple[Any, Log]], Tuple[Any, Log]]) -> 'Writer':
        
        a, w = self.run()
        b, _w = func((a, w))
        return Writer(b, _w)
1371124
def map(self, fn: Callable[[Any], Any]) -> 'Reader':
        
        """
        def _compose(x: Any) -> Any:
            try:
                ret = fn(self.run(x))
            except TypeError:
                ret = partial(fn, self.run(x))
            return ret
        return Reader(_compose)