Answers for "python pipe select where dedup"

0

python pipe select where dedup

# 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]
)
Posted by: Guest on October-28-2021

Python Answers by Framework

Browse Popular Code Answers by Language