Hacker News new | ask | show | jobs
by tandav 1101 days ago
My library solves 2 problems.

1. It does not require to wrap your iterable into some wrapper to use functional methods. It takes an iterable/object and returns another iterable/object. You don't have to unwrap it after transformations.

2. it uses oneliners (library is 80LOC single file) for most of the methods. You can just copy-paste it to use instead of install and import. E.g map, filter, reduce is just:

    class B:
        def __init__(self, f): self.f = f
    class Pipe  (B): __ror__ = lambda self, x: self.f(x)
    class Map   (B): __ror__ = lambda self, x: map   (self.f, x)
    class Filter(B): __ror__ = lambda self, x: filter(self.f, x)
    class Reduce(B): __ror__ = lambda self, it: functools.reduce(self.f, it, *self.args)