EagerQList
Bases: list
EagerQList
is a python list extension that adds several chainable, methods to the standard list
.
Found in qwlist.eager.EagerQList
Source code in src\qwlist\eager.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
enumerate(start=0)
Returns a Lazy
object with index-value pairs as its elements. Index starts at
the given position start
(defaults to 0).
Returns: Lazy[tuple[int, T]]
Examples:
>>> EagerQList(['a', 'b', 'c']).enumerate()
[(0, 'a'), (1, 'b'), (2, 'c')]
Source code in src\qwlist\eager.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
filter(pred)
Returns an EagerQList
containing all values from this EagerQList
for which
the predicate holds true.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pred |
Callable[[T], bool]
|
|
required |
Returns: EagerQList[T]
Examples:
>>> EagerQList([1, 2, 3, 4]).filter(lambda x: x < 3)
[1, 2]
Source code in src\qwlist\eager.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
flatmap(mapper)
Applies the mapper function to each element of the EagerQList
and flattens the results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapper |
Callable[[T], Iterable[K]]
|
|
required |
Returns: EagerQList[K]
Examples:
>>> EagerQList([1, 2]).flatmap(lambda x: [x, x])
[1, 1, 2, 2]
Source code in src\qwlist\eager.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
flatten()
If self is a EagerQList
of Iterable[T]
flatten concatenates all iterables into a
single list and returns a new EagerQList[T]
.
Returns: EagerQList[T]
Source code in src\qwlist\eager.py
178 179 180 181 182 183 184 185 186 187 |
|
fold(operation, init)
Given the combination operator reduces the EagerQList
by processing
its values, building up the final value.
Other names: fold_left, reduce, accumulate, aggregate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
operation |
Callable[[K, T], K]
|
|
required |
init |
K
|
initial value for the combination operator. |
required |
Returns: K
Examples:
>>> s = EagerQList([1, 2, 3]).fold(lambda acc, x: acc + x, 0)
6
Source code in src\qwlist\eager.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
fold_right(operation, init)
Given the combination operator reduces the EagerQList
by processing
its values, building up the final value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
operation |
Callable[[K, T], K]
|
|
required |
init |
K
|
initial value for the combination operator. |
required |
Returns: K
Examples:
>>> s = EagerQList([1, 2, 3]).fold_right(lambda acc, x: acc + x, 0)
6
Source code in src\qwlist\eager.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
foreach(action)
Applies the given function to each of the EagerQList
elements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action |
Callable[[T], None]
|
|
required |
Returns: None
Source code in src\qwlist\eager.py
72 73 74 75 76 77 78 79 80 81 82 |
|
list()
Changes EagerQList
into list
.
Returns: list[T]
Source code in src\qwlist\eager.py
27 28 29 30 31 32 33 |
|
map(mapper)
Returns an EagerQList
containing all values from this EagerQList
with
the mapping function applied on them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapper |
Callable[[T], K]
|
|
required |
Returns: EagerQList[K]
Source code in src\qwlist\eager.py
60 61 62 63 64 65 66 67 68 69 70 |
|
qlist()
Changes EagerQList
into Qlist
.
Returns: QList[T]
Source code in src\qwlist\eager.py
35 36 37 38 39 40 41 42 |
|
sorted(key=None, reverse=False)
Returns a new EagerQList
containing all items from the original list in ascending order.
A custom key function can be supplied to customize the sort order, and the reverse flag can be set to request the result in descending order.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Callable[[T], SupportsLessThan]
|
|
None
|
reverse |
bool
|
if set to |
False
|
Returns: EagerQList[T]
Source code in src\qwlist\eager.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
zip(other)
Combines this EagerQList
with the given Iterable
elementwise as tuples.
The returned EagerQList
objects has at most the number of elements of
the shorter sequence (self
or Iterable
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Iterable[K]
|
iterable to zip with this |
required |
Returns: EagerQList[tuple[T, K]]
Source code in src\qwlist\eager.py
150 151 152 153 154 155 156 157 158 159 160 161 |
|