Skip to content

Unpacking

unpack_nullary(function: Nullary[R]) -> UnpackNullary[R]

Creates a function that unpacks nullary tuples to call the given function.

Parameters:

Name Type Description Default
function Nullary[R]

The function to call.

required

Returns:

Type Description
UnpackNullary[R]

The unpacking function.

Source code in src/funcs/unpacking.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def unpack_nullary(function: Nullary[R]) -> UnpackNullary[R]:
    """Creates a function that unpacks nullary tuples to call the given `function`.

    Arguments:
        function: The function to call.

    Returns:
        The unpacking function.
    """

    def unpack(items: EmptyTuple) -> R:
        return function()

    return unpack

unpack_unary(function: Unary[T, R]) -> UnpackUnary[T, R]

Creates a function that unpacks unary tuples to call the given function.

Parameters:

Name Type Description Default
function Unary[T, R]

The function to call.

required

Returns:

Type Description
UnpackUnary[T, R]

The unpacking function.

Source code in src/funcs/unpacking.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def unpack_unary(function: Unary[T, R]) -> UnpackUnary[T, R]:
    """Creates a function that unpacks unary tuples to call the given `function`.

    Arguments:
        function: The function to call.

    Returns:
        The unpacking function.
    """

    def unpack(items: Tuple[T]) -> R:
        (t,) = items

        return function(t)

    return unpack

unpack_binary(function: Binary[T, U, R]) -> UnpackBinary[T, U, R]

Creates a function that unpacks binary tuples to call the given function.

Parameters:

Name Type Description Default
function Binary[T, U, R]

The function to call.

required

Returns:

Type Description
UnpackBinary[T, U, R]

The unpacking function.

Source code in src/funcs/unpacking.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def unpack_binary(function: Binary[T, U, R]) -> UnpackBinary[T, U, R]:
    """Creates a function that unpacks binary tuples to call the given `function`.

    Arguments:
        function: The function to call.

    Returns:
        The unpacking function.
    """

    def unpack(items: Tuple[T, U]) -> R:
        (t, u) = items

        return function(t, u)

    return unpack

unpack_ternary(function: Ternary[T, U, V, R]) -> UnpackTernary[T, U, V, R]

Creates a function that unpacks ternary tuples to call the given function.

Parameters:

Name Type Description Default
function Ternary[T, U, V, R]

The function to call.

required

Returns:

Type Description
UnpackTernary[T, U, V, R]

The unpacking function.

Source code in src/funcs/unpacking.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def unpack_ternary(function: Ternary[T, U, V, R]) -> UnpackTernary[T, U, V, R]:
    """Creates a function that unpacks ternary tuples to call the given `function`.

    Arguments:
        function: The function to call.

    Returns:
        The unpacking function.
    """

    def unpack(items: Tuple[T, U, V]) -> R:
        (t, u, v) = items

        return function(t, u, v)

    return unpack

unpack_quaternary(function: Quaternary[T, U, V, W, R]) -> UnpackQuaternary[T, U, V, W, R]

Creates a function that unpacks quaternary tuples to call the given function.

Parameters:

Name Type Description Default
function Quaternary[T, U, V, W, R]

The function to call.

required

Returns:

Type Description
UnpackQuaternary[T, U, V, W, R]

The unpacking function.

Source code in src/funcs/unpacking.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def unpack_quaternary(function: Quaternary[T, U, V, W, R]) -> UnpackQuaternary[T, U, V, W, R]:
    """Creates a function that unpacks quaternary tuples to call the given `function`.

    Arguments:
        function: The function to call.

    Returns:
        The unpacking function.
    """

    def unpack(items: Tuple[T, U, V, W]) -> R:
        (t, u, v, w) = items

        return function(t, u, v, w)

    return unpack