Comments (2)
Actually I should have read the docs closer!
I see how [1, 2, 3, 4] | p(map, px + 1)
works as list comprehension would, but I can't do dictionary comprehension or use the reduce
function for that matter.
Perhaps I'm not using the library correctly?
from sspipe.
Thanks for your feedback.
Currently, sspipe supports p(map, px)
and p(filter, px)
natively, but it doesn't support p(reduce, px)
natively yet. But you can use still use it with reduce like this:
>>> [1, 2, 3, 4] | p(lambda l: reduce(lambda x, y: x+y, l))
10
For dict comprehension, you can generate a list of [key, value] pairs and pass it to dict:
>>> [1, 2, 3, 4] | p(map, p([p(str), px%2])) | p(dict)
{'1': 1, '2': 0, '3': 1, '4': 0}
from sspipe.
Related Issues (13)
- TypeError: 'Pipe' object cannot be interpreted as an integer HOT 2
- 1 | p(print, "%s" %px) does not work as intended HOT 1
- Stuck when zipping HOT 1
- AttributeError: module 'pipe' has no attribute '__all__' HOT 2
- A composition framework that involves sspipe HOT 1
- Question: Applying multiple operations in one call to p HOT 3
- Incluye sspipe module as parte of the Stsndard Library
- Include sspipe module as part of the Standard Library HOT 3
- `TypeError` on conditional HOT 3
- why does the following crash jupyternotebook kernel? HOT 2
- provide some insights among all these different pipe packages HOT 1
- Questions: unpipe() and general compatibility
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sspipe.