3 ms·
shameless plug: I maintain a small library to do functional pipes. You can write: ( range(10) | Map(lambda x: x * 10) | Filter(lamb
by tandav 3y ago
shameless plug: I maintain a small library to do functional pipes.
You can write:
(
range(10)
| Map(lambda x: x * 10)
| Filter(lambda x: x % 2 == 0)
| Reduce(lambda a, b: a + b)
)
and more. https://tandav.github.io/pipe21/ https://tandav.github.io/pipe21/
most operators are basically oneliners: https://github.com/tandav/pipe21/blob/master/pipe21.py#L17 https://github.com/tandav/pipe21/blob/master/pipe21.py#L17
I also maintain a list of libraries which uses pipeline/chain syntax: https://tandav.github.io/pipe21/similar-tools/ https://tandav.github.io/pipe21/similar-tools/
- throwaway914 3y agoThis is very cool. I remember I got sucked into things like Ramda going down this functional programming rabbit hole :-) https://ramdajs.com/ https://ramdajs.com/
- retrocryptid 3y agoThe first thing I did when I encountered js in the 90s was write map and reduce. After leaving Mozilla I published a npm package with my hacks. I was very happy to find someone else had done a much better job at it and was actually maintaining it. also, have you seen lazyjs? Also very cool.