Custom pipes
Project description
Custom pipes
Description
This pack has some custom pipes to work with the pipe package.
This package is compatible with python 3.
Pipes
reduce
list1 = [1, 2, 3, 4, 5, 6, 7]
result = list1 | reduce(lambda a, b: a + b)
list1 = []
# raises TypeError
_ = list1 | reduce(lambda a, b: a + b)
list1 = [1]
result = list1 | reduce(lambda a, b: a + b)
fold
list1 = [1, 2, 3, 4, 5, 6, 7]
result = list1 | fold(lambda a, b: a + b, 0)
list1 = [1, 2, 3, 4, 5, 6, 7]
result = list1 | fold(lambda a, b: f"{a}/{b}" if a else f"{b}", "")
list1 = []
_ = list1 | fold(lambda a, b: f"{a}/{b}" if a else f"{b}", "")
deep_flatten
list1 = [[1,2], [3,4]]
# result is [1, 2, 3, 4]
result = list(list1 | deep_flatten())
result = list(1 | deep_flatten())
# result is [1]
list1 = [1, 2, 3, 4]
# result is [1, 2, 3, 4]
result = list(list1 | deep_flatten())
list1 = [[1,2], [3, [4, 5]]]
# result is [1, 2, 3, 4, 5]
result = list(list1 | deep_flatten())
list1 = [[1,2], [3, [4, [5, 6]]]]
# result is [1, 2, 3, 4, 5, 6]
result = list(list1 | deep_flatten())
deep_flatmap
list1:list[int] = [1, 2, 3, 4]
# result is [2, 3, 4, 5]
result = list(list1 | deep_flatmap(lambda x: x+1))
list1 = [[1, 2], [3, 4]]
# result is [2, 3, 4, 5]
result = list(list1 | deep_flatmap(lambda x: x+1))
list1 = [[1, 2], [3, [4]]]
# result is [2, 3, 4, 5]
result = list(list1 | deep_flatmap(lambda x: x+1))
result = list(1 | deep_flatmap(lambda x: x))
# result is [1]
flatten
list1 = [[1, 2], [3, 4]]
# result is [1, 2, 3, 4]
result = list(list1 | flatten())
list1 = [1, 2, 3, 4]
# raises TypeError
_ = list(list1 | flatten())
list1 = [[[1, 2]], [[3, 4]]]
# result is [[1, 2], [3, 4]]
result = list(list1 | flatten())
flatmap
list1:list = [1, 2, 3, 4]
# raises TypeError
_ = list(list1 | flatmap(lambda x: x+1))
list1 = [[1, 2], [3, [4]]]
# raises TypeError
_ = list(list1 | flatmap(lambda x: x+1))
# raises TypeError
_ = list(1 | flatmap(lambda x: x+1))
list1:list = [[1, 2], [3, 4]]
# result is [2, 3, 4, 5]
result = list(list1 | flatmap(lambda x: x+1))
as_dict
data = [(1, 2), (3, 4)]
# result {1:2, 3:4}
result = data | as_dict()
as_list
data = range(1, 5)
# result is = [1, 2, 3, 4]
result = data | as_list()
as_set
data = [1, 2, 3, 4]
# result {1, 2, 3, 4}
result = data | as_set()
split
data = [1, 2, 3, 4]
# result is ([2, 4], [1, 3])
result = data | split(lambda x: x%2==0)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xi_pipes-0.0.3.tar.gz
(3.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xi_pipes-0.0.3.tar.gz.
File metadata
- Download URL: xi_pipes-0.0.3.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8664f817724957f7c9456803b7009d37324ecf980ea29c942e7e41de5a6901d6
|
|
| MD5 |
a24524769e66107ec8319f91960c2106
|
|
| BLAKE2b-256 |
dfdf1ba64e35bed222a560ed9317dacc82d0e5a92fa630507076ccd57cd98b4f
|
File details
Details for the file xi_pipes-0.0.3-py3-none-any.whl.
File metadata
- Download URL: xi_pipes-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74304bde8ea30ac1bc29a6fb9b411cd04457769cf485a8e874e4c5d9c95e8744
|
|
| MD5 |
09ffcd383ec306994f69434017f724c0
|
|
| BLAKE2b-256 |
f4fbefbf6143ae38b69c5b97f3e04595a59ac43bcd44db8a4a8fabac74a4f287
|