Skip to content

pfun.operator.lt(a, b)

Return a < b, for a and b.

Examples:

>>> lt(1)(2)
True

Parameters:

Name Type Description Default
a pfun.protocols.SupportsLt[~A, ~B]

left element of lt expression

required
b ~A

right element of lt expression

required

Returns:

Type Description
~B

True if a < b, False otherwise

pfun.operator.le(a, b)

Return a <= b, for a and b.

Examples:

>>> le(1)(2)
True

Parameters:

Name Type Description Default
a pfun.protocols.SupportsLe[~A, ~B]

left element of le expression

required
b ~A

right element of le expression

required

Returns:

Type Description
~B

True if a <= b, False otherwise

pfun.operator.eq(a, b)

Return a == b, for a and b.

Examples:

>>> eq(2)(2)
True

Parameters:

Name Type Description Default
a object

left element of eq expression

required
b object

right element of eq expression

required

Returns:

Type Description
bool

True if a == b, False otherwise

pfun.operator.ne(a, b)

Return a != b, for a and b.

Examples:

>>> ne(2)(2)
False

Parameters:

Name Type Description Default
a object

left element of ne expression

required
b object

right element of ne expression

required

Returns:

Type Description
bool

True if a != b, False otherwise

pfun.operator.gt(a, b)

Return a > b, for a and b.

Examples:

>>> gt(1)(2)
False

Parameters:

Name Type Description Default
a pfun.protocols.SupportsGt[~A, ~B]

left element of gt expression

required
b ~A

right element of gt expression

required

Returns:

Type Description
~B

True if a > b, False otherwise

pfun.operator.not_(a)

Return not a, for a.

Examples:

>>> not_(True)
False

Parameters:

Name Type Description Default
a object

argument of not expression

required

Returns:

Type Description
bool

False if a, True otherwise

pfun.operator.truth(a)

Return bool(a), for a.

Examples:

>>> truth(True)
True

Parameters:

Name Type Description Default
a object

argument of bool expression

required

Returns:

Type Description
bool

True if a, False otherwise

pfun.operator.is_(a, b)

Return a is b, for a and b.

Examples:

>>> is_(object())(object())
False

Parameters:

Name Type Description Default
a object

left element of is expression

required
b object

right element of is expression

required

Returns:

Type Description
bool

True if a is b, False otherwise

pfun.operator.is_not(a, b)

Return a is not b, for a and b.

Examples:

>>> is_not(object())(object())
True

Parameters:

Name Type Description Default
a object

left element of is not expression

required
b object

right element of is not expression

required

Returns:

Type Description
bool

False if a is b, True otherwise

pfun.operator.add(a, b)

Return a + b, for a and b.

Examples:

>>> add(2)(2)
4

Parameters:

Name Type Description Default
a pfun.protocols.SupportsAdd[~A, ~B]

left element of add expression

required
b ~A

right element of add expression

required

Returns:

Type Description
~B

b added to a

pfun.operator.abs(a)

Return builtin abs(a), for a.

Examples:

>>> abs(-2)
2

Parameters:

Name Type Description Default
a pfun.protocols.SupportsAbs[~A]

element of abs expression

required

Returns:

Type Description
~A

b added to a

pfun.operator.and_(a)

Return a and b, for a and b.

Examples:

>>> and_(True)(False)
False

Parameters:

Name Type Description Default
a

left element of and_ expression

required
b

right element of and_ expression

required

Returns:

Type Description
Callable[[~A], ~B]

True if both a and b, False otherwise

pfun.operator.floordiv(a, b)

Return a // b, for a and b.

Examples:

>>> floordiv(2)(3)
0

Parameters:

Name Type Description Default
a pfun.protocols.SupportsFloorDiv[~A, ~B]

left element of // expression

required
b ~A

right element of // expression

required

Returns:

Type Description
~B

b added to a

pfun.operator.index(a)

Return a converted to an integer. Equivalent to a.index().

Examples:

>>> class Index:
...     def __index__(self) -> int:
...         return 0
>>> [1][Index()]
1

Parameters:

Name Type Description Default
a SupportsIndex required

pfun.operator.invert(a)

Return ~a for a.

Examples:

>>> invert(2)
-3

Parameters:

Name Type Description Default
a pfun.protocols.SupportsInvert[~A]

value to invert

required

Returns:

Type Description
~A

~a

pfun.operator.lshift(a, b)

Return a << b, for a and b.

Examples:

>>> lshift(2)(3)
0

Parameters:

Name Type Description Default
a pfun.protocols.SupportsLShift[~A, ~B]

left element of << expression

required
b ~A

right element of << expression

required

Returns:

Type Description
~B

a lshifted by b

pfun.operator.mod(a, b)

Return a % b, for a and b.

Examples:

>>> mod(2)(3)
2

Parameters:

Name Type Description Default
a pfun.protocols.SupportsMod[~A, ~B]

left element of % expression

required
b ~A

right element of % expression

required

Returns:

Type Description
~B

a modulo b

pfun.operator.mul(a, b)

Return a * b, for a and b.

Examples:

>>> mul(2)(3)
6

Parameters:

Name Type Description Default
a pfun.protocols.SupportsMul[~A, ~B]

left element of * expression

required
b ~A

right element of * expression

required

Returns:

Type Description
~B

a multiplied by b

pfun.operator.matmul(a, b)

Return a @ b, for a and b.

Examples:

>>> import numpy as np
>>> m = np.arange(3)
>>> matmul(m)(m)
5

Parameters:

Name Type Description Default
a pfun.protocols.SupportsMatMul[~A, ~B]

left element of @ expression

required
b ~A

right element of @ expression

required

Returns:

Type Description
~B

a @ b

pfun.operator.neg(a)

Return -a.

Examples:

>>> neg(5)
-5

Parameters:

Name Type Description Default
a pfun.protocols.SupportsNeg[~A]

element of negation expression

required

Returns:

Type Description
~A

-a

pfun.operator.or_(a)

Return a or b, for a and b.

Examples:

>>> or_(True)(False)
True

Parameters:

Name Type Description Default
a

left element of or expression

required
b

right element of or expression

required

Returns:

Type Description
Callable[[~A], ~B]

True if either a or b, False otherwise

pfun.operator.pos(a)

Return +a.

Examples:

>>> pos(-5)
-5

Parameters:

Name Type Description Default
a pfun.protocols.SupportsPos[~A]

element of pos expression

required

Returns:

Type Description
~A

+a

pfun.operator.pow(a, b)

Return a ** b, for a and b.

Examples:

>>> pow(2)(2)
4

Parameters:

Name Type Description Default
a pfun.protocols.SupportsPow[~A, ~B]

left element of ** expression

required
b ~A

right element of ** expression

required

Returns:

Type Description
~B

a ** b

pfun.operator.rshift(a, b)

Return a >> b, for a and b.

Examples:

>>> rshift(2)(3)
0

Parameters:

Name Type Description Default
a pfun.protocols.SupportsRShift[~A, ~B]

left element of >> expression

required
b ~A

right element of >> expression

required

Returns:

Type Description
~B

a rshifted by b

pfun.operator.sub(a, b)

Return a - b, for a and b.

Examples:

>>> sub(2)(2)
0

Parameters:

Name Type Description Default
a pfun.protocols.SupportsSub[~A, ~B]

left element of - expression

required
b ~A

right element of - expression

required

Returns:

Type Description
~B

a - b

pfun.operator.truediv(a, b)

Return a / b, for a and b.

Examples:

>>> truediv(2)(2)
1.0

Parameters:

Name Type Description Default
a pfun.protocols.SupportsTrueDiv[~A, ~B]

left element of / expression

required
b ~A

right element of / expression

required

Returns:

Type Description
~B

a / b

pfun.operator.xor(a, b)

Return a ^ b, for a and b.

Examples:

>>> xor(2)(2)
0

Parameters:

Name Type Description Default
a pfun.protocols.SupportsXor[~A, ~B]

left element of ^ expression

required
b ~A

right element of ^ expression

required

Returns:

Type Description
~B

a ^ b

pfun.operator.contains(elem, container)

Return elem in container, for elem and container. Note that the order of arguments are flipped comparet to the builtins operator module

Examples:

>>> contains(2)([1, 2, 3])
True

Parameters:

Name Type Description Default
elem ~A

left element of in expression

required
container Container[~A]

right element of in expression

required

Returns:

Type Description
bool

elem in container

pfun.operator.count_of(elem, container)

Return count of how many times elem appears in container. Note that the order of arguments are flipped comparet to the builtins operator module

Examples:

>>> count_of(2)([1, 2, 3])
1

Parameters:

Name Type Description Default
elem ~A

left element of in expression

required
container Container[~A]

right element of in expression

required

Returns:

Type Description
int

elem in container

pfun.operator.get_item(index, container)

Return element at index in container. Note that the order of arguments are flipped comparet to the builtins operator module

Examples:

>>> get_item(1)([1, 2, 3])
2

Parameters:

Name Type Description Default
index ~A

value to use as index

required
container pfun.protocols.SupportsGetItem[~A, ~B]

container to index with index

required

Returns:

Type Description
Optional[~B]

container[index]

pfun.operator.length_hint(a, default=0)

Return an estimated length for the object o. First try to return its actual length, then an estimate using a.__length_hint__(), and finally return the default value.

Examples:

>>> length_hint([])
0

Parameters:

Name Type Description Default
a SupportsLengthHint

value to compute length hint from

required

Returns:

Type Description
int

Length hint as an int