📜  python pipe select where dedup - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:24.740000             🧑  作者: Mango

代码示例1
# pip install pipe
from pipe import select, where, dedup


arr = [1,2,3,4,5,4,3,2,1,1,1]

res = list(arr
    | dedup                      # remove duplicates -> [1,2,3,4,5]
    | where(lambda e: e%2 == 0)  # filter for even numbers -> [2,4]
    | select(lambda e: e * 2)    # double all numbers -> [4,8]
)