pfun.list.List
__add__(self, other)
special
Concatenate with other Iterable
or List
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Iterable[~A] |
Iterable to concatenate with |
required |
Returns:
Type | Description |
---|---|
List[A] |
new |
__radd__(self, other)
special
Concatenate with other Iterable
or List
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Iterable[~A] |
Iterable to concatenate with |
required |
Returns:
Type | Description |
---|---|
List[A] |
new |
and_then(self, f)
Chain together functions that produce more than one result
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Callable[[A], List[B]] |
Function to apply to elements of this |
required |
Returns:
Type | Description |
---|---|
List[B] |
Concatenated results from applying |
append(self, a)
Add element to end of list
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
~A |
Element to append |
required |
Returns:
Type | Description |
---|---|
List[A] |
New |
extend(self, iterable)
Add all elements from iterable
to end of list
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iterable |
Iterable[~A] |
Iterable to extend by |
required |
Returns:
Type | Description |
---|---|
List[A] |
New |
filter(self, f)
Filter elements by the predicate f
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Callable[[~A], bool] |
Function to filter by |
required |
Returns:
Type | Description |
---|---|
List[A] |
new |
map(self, f)
Apply f
to each element in the list
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Callable[[~A], ~B] |
Function to apply |
required |
Returns:
Type | Description |
---|---|
List[B] |
new |
reduce(self, f, initializer=None)
Aggregate elements by f
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Callable[[~B, ~A], ~B] |
Function to perform aggregation |
required |
initializer |
Optional[~B] |
Starting value for aggregation |
None |
Returns:
Type | Description |
---|---|
~B |
Aggregated result |
zip(self, other)
Zip together with another iterable
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
other |
Iterable[~B] |
Iterable to zip with |
required |
Returns:
Type | Description |
---|---|
Iterable[Tuple[~A, ~B]] |
Zip with |
pfun.list.for_each(f, iterable)
Map each in element in iterable
to
an List
by applying f
,
combine the elements by and_then
from left to right and collect the results
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Callable[[~A], pfun.list.List[~B]] |
Function to map over |
required |
iterable |
Iterable[~A] |
Iterable to map |
required |
Returns:
Type | Description |
---|---|
pfun.list.List[Iterable[~B]] |
|
pfun.list.sequence(iterable)
Evaluate each List
in iterable
from left to right
and collect the results
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iterable |
Iterable[pfun.list.List[~A]] |
The iterable to collect results from |
required |
Returns:
Type | Description |
---|---|
pfun.list.List[Iterable[~A]] |
|
pfun.list.filter_(f, iterable)
Map each element in iterable
by applying f
,
filter the results by the value returned by f
and combine from left to right.
Examples:
1 2 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f |
Callable[[~A], pfun.list.List[bool]] |
Function to map |
required |
iterable |
Iterable[~A] |
Iterable to map by |
required |
Returns:
Type | Description |
---|---|
pfun.list.List[Iterable[~A]] |
|