Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python pipe

# 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]
)

print(res)  # -> [4,8]
 
PREVIOUS NEXT
Tagged: #python #pipe
ADD COMMENT
Topic
Name
8+4 =