Skip to content

Commit 1972769

Browse files
Add custom_equation and fn_w_counter functions
Implement custom polynomial equation and counter function.
1 parent 8cfff6e commit 1972769

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
custom_power = lambda x= 0, /, e = 1: x ** e
2+
3+
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
4+
"""Calculate custom polynomial equation result.
5+
6+
Calculates :math:`\\frac{x^a + y^b}{c}`.
7+
8+
:param x: Positional-only x value, defaults to 0
9+
:type x: int, optional
10+
:param y: Positional-only y value, defaults to 0
11+
:type y: int, optional
12+
:param a: Positional-or-keyword exponent for x, defaults to 1
13+
:type a: int, optional
14+
:param b: Positional-or-keyword exponent for y, defaults to 1
15+
:type b: int, optional
16+
:param c: Keyword-only denominator, defaults to 1
17+
:type c: int, optional
18+
:return: Result of (x**a + y**b) / c
19+
:rtype: float
20+
"""
21+
return (x**a + y**b) / c
22+
23+
def fn_w_counter() -> (int, dict[str, int]):
24+
if not hasattr(fn_w_counter, "counter"):
25+
fn_w_counter.counter = 0
26+
fn_w_counter.counter += 1
27+
return (fn_w_counter.counter, {fn_w_counter.__module__: fn_w_counter.counter})
28+
if __name__ == "__main__":
29+
print(fn_w_counter())

0 commit comments

Comments
 (0)