partial#

swordfish.partial(func, *args, **kwargs)#

Creates a partially applied function by binding arguments to the original function.

Parameters:
  • func (FunctionDef) – The original function to partially apply arguments to.

  • *args – Positional arguments to bind to the function.

  • **kwargs – Keyword arguments to bind to the function.

Returns:

A Swordfish FunctionDef object representing the partially applied function.

Return type:

FunctionDef

Examples

>>> import swordfish as sf
>>> import swordfish.function as F
>>> @F.swordfish_udf
>>> def add(a,b):
...    return a+b
>>> partial_func1 = sf.partial(add, 1)
>>> partial_func1(3)
Long(4)
>>> partial_func2 = sf.partial(add, b=4)
>>> partial_func2(3)
Long(7)