aspis.common.curry

aspis.common.curry(fn)[source]

Transforms a function into a curried version.

Parameters:

fn (Callable) – The function to be curried.

Returns:

A curried version of the original function.

Return type:

Callable

Examples

  1. Using curry directly:

    >>> def add(a, b, c):
    ...     return a + b + c
    
    >>> curried_add = curry(add)
    >>> result = curried_add(1)(2)(3)  # returns 6
    
  2. Using curry as a decorator:

    >>> @curry
    ... def multiply(a, b):
    ...     return a * b
    
    >>> result = multiply(2)(3)  # returns 6