Skip to content

Primitives

increment(x: int) -> int

Increments x by 1.

Parameters:

Name Type Description Default
x int

The value to increment.

required

Returns:

Type Description
int

The incremented value.

Source code in src/funcs/primitives.py
 6
 7
 8
 9
10
11
12
13
14
15
def increment(x: int) -> int:
    """Increments `x` by 1.

    Arguments:
        x: The value to increment.

    Returns:
        The incremented value.
    """
    return x + 1

decrement(x: int) -> int

Decrements x by 1.

Parameters:

Name Type Description Default
x int

The value to decrement.

required

Returns:

Type Description
int

The decremented value.

Source code in src/funcs/primitives.py
18
19
20
21
22
23
24
25
26
27
def decrement(x: int) -> int:
    """Decrements `x` by 1.

    Arguments:
        x: The value to decrement.

    Returns:
        The decremented value.
    """
    return x - 1

is_even(x: int) -> bool

Checks if x is even.

Parameters:

Name Type Description Default
x int

The value to check.

required

Returns:

Type Description
bool

Whether x is even.

Source code in src/funcs/primitives.py
30
31
32
33
34
35
36
37
38
39
def is_even(x: int) -> bool:
    """Checks if `x` is even.

    Arguments:
        x: The value to check.

    Returns:
        Whether `x` is even.
    """
    return not x % 2

is_odd(x: int) -> bool

Checks if x is odd.

Parameters:

Name Type Description Default
x int

The value to check.

required

Returns:

Type Description
bool

Whether x is odd.

Source code in src/funcs/primitives.py
42
43
44
45
46
47
48
49
50
51
def is_odd(x: int) -> bool:
    """Checks if `x` is odd.

    Arguments:
        x: The value to check.

    Returns:
        Whether `x` is odd.
    """
    return not is_even(x)