Quick actions

cmd+k|ctrl+k

Navigation

Languages

Pipes

Snippet info

Language

Python

Visibility

public

Author

linus.aspelin

Created

2018-12-08T21:20:30Z

Updated

2018-12-08T21:20:30Z

class pipe():
    def __init__(self, old, unpack_args=False):
        self.old = old
        self.unpack = unpack_args
        
    def __ror__(self, other):
        if self.unpack:
            return self(*other)
        return self(other)

    def __call__(self, *args, **kwargs):
        return self.old(*args, **kwargs)

sum = pipe(sum)
map = pipe(map, True)

tuple_list = [(1,2),(3,4),(5,6)]

max_sum = (max, tuple_list) | map | sum

print(max_sum)
INFO