17
17
18
18
19
19
def sort_inplace (data : list [T ] | Container [T ]) -> None :
20
- """Sort a list or Container in place.
20
+ """Sort a container in-place.
21
+
22
+ Sorts the elements in the container in ascending order.
21
23
22
24
Parameters
23
25
----------
24
- data : list[T] or Container[T]
25
- The data structure to sort
26
+ data : list[T] | Container[T]
27
+ The container to sort in-place
26
28
27
29
Examples
28
30
--------
@@ -41,17 +43,20 @@ def sort_inplace(data: list[T] | Container[T]) -> None:
41
43
def count_if (data : Iterable [T ], predicate : Callable [[T ], bool ]) -> int :
42
44
"""Count elements in a sequence that satisfy a predicate.
43
45
46
+ Counts the number of elements in the sequence for which the predicate
47
+ returns true.
48
+
44
49
Parameters
45
50
----------
46
51
data : Iterable[T]
47
- The data to search through
52
+ The input sequence to examine
48
53
predicate : Callable[[T], bool]
49
- Function to test each element
54
+ The predicate function to test each element
50
55
51
56
Returns
52
57
-------
53
58
int
54
- Number of elements matching the predicate
59
+ The number of elements that satisfy the predicate
55
60
56
61
Examples
57
62
--------
@@ -72,17 +77,20 @@ def count_if(data: Iterable[T], predicate: Callable[[T], bool]) -> int:
72
77
def transform_to_list (data : Iterable [T ], func : Callable [[T ], U ]) -> list [U ]:
73
78
"""Transform a sequence into a list using a transformation function.
74
79
80
+ Applies the transformation function to each element in the input sequence
81
+ and collects the results in a new list.
82
+
75
83
Parameters
76
84
----------
77
85
data : Iterable[T]
78
- The data to transform
86
+ The input sequence to transform
79
87
func : Callable[[T], U]
80
- Function to apply to each element
88
+ The transformation function to apply to each element
81
89
82
90
Returns
83
91
-------
84
92
list[U]
85
- List of transformed elements
93
+ A list containing the transformed elements
86
94
87
95
Examples
88
96
--------
@@ -107,13 +115,13 @@ def find_min_max(
107
115
108
116
Parameters
109
117
----------
110
- data : Iterable[T ]
111
- The sequence to search
118
+ data : Iterable[SupportsRichComparisonT ]
119
+ The input sequence to search for minimum and maximum elements
112
120
113
121
Returns
114
122
-------
115
- tuple[T, T ]
116
- Tuple containing ( minimum, maximum) values
123
+ tuple[SupportsRichComparisonT, SupportsRichComparisonT ]
124
+ A tuple containing the minimum and maximum elements (min, max)
117
125
"""
118
126
match data :
119
127
case list () | tuple ():
@@ -127,15 +135,17 @@ def find_min_max(
127
135
def pipeline (* functions : Callable [[Any ], Any ]) -> Callable [[Any ], Any ]:
128
136
"""Create a function pipeline.
129
137
138
+ Creates a function that applies a sequence of functions in a pipeline.
139
+
130
140
Parameters
131
141
----------
132
142
*functions : Callable[[Any], Any]
133
- Functions to compose in pipeline order
143
+ The functions to compose in pipeline order
134
144
135
145
Returns
136
146
-------
137
147
Callable[[Any], Any]
138
- Composed function that applies all functions in sequence
148
+ A composed function that applies all functions in sequence
139
149
140
150
Examples
141
151
--------
0 commit comments